I'm add some css and js like:

// Single
bundles.Add(new ScriptBundle("~/res/js/single").Include(
    "~/res/js/jquery.js",// jQuery
));



// Main CSS
bundles.Add(new StyleBundle("~/res/css/css").Include(
      "~/res/css/MainStyle.css"
);

Then When I display it use:

@Styles.Render("~/res/css/single")
@Styles.Render("~/res/css/css")

It will display like this:

<link href="/res/css/css?v=-BDAI2AgglVOdcoS8Lr_ikUbMwTr-Vu9Jj0seHx5B81" rel="stylesheet"/>
<script src="/res/js/single?v=sbFboOuLdtmhD0n_uFzollmELtGkgdU5cTntphHFa-01"></script>

But I need it use full path, which mean include the base address on front. like:

<link href="http://www.xx.com/res/css/css?v=-BDAI2AgglVOdcoS8Lr_ikUbMwTr-Vu9Jj0seHx5B81" rel="stylesheet"/>
<script src="http://www.xx.com/res/js/single?v=sbFboOuLdtmhD0n_uFzollmELtGkgdU5cTntphHFa-01"></script>

So Is there a good way can display the full path. Why I do that? because maybe I want cache the js, css. use other domain name. only for CDN. maybe I will change the base domain to CDN domain...

I'm working on asp.net mvc single page application. I've tried to use custom knockout binding for bootstrap widgets. Here is the link http://billpull.com/knockout-bootstrap/ But it doesn't work for me and there are no errors. Any ideas how to get it work or maybe references to others plugins ?

Thanks.

I am just about to start building a large application which will perform different methods of string encryption on text files. This is going to end up being a fairly large application so I'd like to be sure that the design I have is good from the beginning. I have taken a look at the Model-View-View Model design pattern however since there will be no data being passed back to the view I don't think that this is the best pattern to use. The purpose of the application is literally to just perform a string encryption method on arbitrary text files and then display a message box (System.Windows.MessageBox). This message box will only give a standard success or failure message based on whether the process succeeded. Is MVC a more appropriate pattern here? I know that this is fairly uncommon and that MVVM seems to be the pattern of choice but, again, I feel that since no data is being passed back to the view that MVVM is inappropriate.

The interface for this application will only be a few text boxes which are used to select the encryption method and a button that, when clicked, will perform the appropriate encryption method.

I am new to ROR and spent most of the day trying to get this to work. I have tried using the before_filter and I cannot get my object to insert in another method.

The view is index, a file is selected in the view and then the button to validate file is clicked which calls a method 'evaluate_media' in this method, I look up values based on the file path and name selected and I can successfully insert the record with all the values in this method. The problem is I don't want an automatic save. When the 'evaluate_media' method is done it displays back with either a save button or an update button based on if the file submitted already exists in the database. Then the user can choose to save/update the record or now. This button calls the 'save_file' action. The problem is all the information save in 'evaluate_media' action for the file is not accessible to save_file or update_file actions. I believe session variables might be my answer but I could not find any good examples to get it setup correctly and working in my application. Can someone please tell me and show me the proper code to pass the value from 'evaluate_media' action to save_file or update_file actions?

Here is the code where I assign the values for a new record in my evaluaate_media method:

   if @file_exists_flag == 'NEW'
      # Assign Parameter values for new save
      @file_alias_tfile = FileAliasTfile.new( {:src_location => @radio_button_value, :directory => @dir_path_choice, :full_path => @selected_filepath, :full_filename => @filepath, :file_ext => '', 
                                                  :assigned_status => 'Unassigned', :file_status => 'Saved', :alias_code => @file_alias.to_s, :validate_status => @file_status.to_s, :error_msg => @file_msg.to_s, 
                                                  :video_alias_match => @msg_dtl1.to_s, :audio_alias_match => @msg_dtl2.to_s, :video_format => @video_format.to_s, :video_bitrate => @video_bitrate.to_s, 
                                                  :video_width => @video_width.to_s,
                                                  :video_height => @video_height.to_s, :video_framerate => @video_framerate.to_s, :video_aspect_ratio => @video_aspectratio.to_s, :video_scan_type => @video_scantype.to_s,
                                                  :video_scan_order => @video_scanorder.to_s, :video_alias_code => '', :audio_alias_code => '', :bus_prod_initiative_id => 0, :status => 'Active', :start_date => DateTime.now.to_date, 
                                                  :end_date => '', :deleted_b => 0, :created_by => 'admin', :updated_by => 'admin'} )


   end

Then if the user clicks the save, the save_file method is called and here is the code to save the values from evaluate_media into the database:

def save_file
    @file_alias_tfile = FileAliasTfile.create(@file_alias_tfile) 
    @file_alias_tfile.save
end

I figure the update will be the same as the save so I only included one case here. Your help is appreciated. Thank you!

I am trying to send text to a asp:TextBox depending on the user selection of a radio button list. The logic here is that the user is asked where he wants to donate. Depending on what he picks Agency or County he will be given the option of choosing an option from a asp:DropDownList or manually enter their selection in a different textbox. The trouble I am having is, the textbox always fills in with the info from the dropdown list even when the condition is true:

strDonateChoice = radCountyOrAgency.SelectedValue;
        switch (strDonateChoice)
        {
            case "County":
                if ((chkOtherCounty.Checked == true) || (txtOtherCounty.Text.Length > 4))
                {
                    txtHCounty.Text = txtOtherCounty.Text;
                    txtHAgency.Text = " ";
                }
                else
                {
                    txtHCounty.Text = ddlCounties.SelectedValue;
                    txtHAgency.Text = " ";
                }
                break;
            case "Agency":
                if ((chkOtherAgency.Checked == true) || (txtOtherAgency.Text.Length > 4))
                {
                    txtHAgency.Text = txtOtherAgency.Text;
                    txtHCounty.Text = " ";
                }
                else
                {
                    txtHAgency.Text = ddlAgency.SelectedValue;
                    txtHCounty.Text = " ";
                }
                break;
            case "Most Needed":
                txtHCounty.Text = "Not Designated";
                txtHAgency.Text = "Not Designated";
                break;

        } 

I am statically populating the following checkbox control from the datatable columnFilter plugin, passing a value and label:

}).columnFilter({sPlaceHolder: "head:before",
  aoColumns: [{ type: "select" },
  { type: "text" },
  {
    type: "checkbox",
      values: 
        [
          { value: 'ENG', label: ' English' },
          { value: 'POR', label: ' Portuguese' },
        ]
   },

However, I need to retrieve those values from a controller, so then the following ajax call was created: $.ajax({ type: "POST", url: "/Skill/SkillsLanguages", async: false, contentType: "application/json; charset=utf-8", success: function (response) { SkillLang = response; } });

Controller looks like: public ActionResult SkillsLanguages(JQueryDataTableParamModel param) { string[,] languages = new string[1, 2] { { "ENG" , "English" }

     };

     return Json(languages);

And now I am trying to populate the check box using the response from the Ajax call to the MVC controller:

}).columnFilter({sPlaceHolder: "head:before",
  aoColumns: [{ type: "select" },
    { type: "text" },
    {
       type: "checkbox",
       values: skillLang
    },

This is not working quite right, and instead of creating an entry in the checkbox with a pair of value/label, I end up having two different rows, i.e.: ENG English

Any idea how to solve this?

Thanks in advance!

Is it possible to use EditorFor Template inside a DisplayFor Template? When I do this currently, my model that I pass to the EditorFor template is NULL. I am not sure if I using this properly.

public List<TargetingAreaViewModel> TargetingAreaOrderItems { get; set; }
public List<TargetingAreaItemViewModel> TargetingAreaItems { get; set; }

@model SimplifiedAdvertising.Web.Models.SignupModels.TargetingAreaViewModel
@{
ApplicationContext.Current.PageTitle = "Targeting Info";
Layout = "~/Views/Shared/_LeftNavLayout.cshtml";
Html.UI().PageHeader.Title = "Targeting Info";
Html.UI().PageHeader.AddSaveButton(1);
Html.UI().PageHeader.AddBreadcrumb("Packages", "SeasonIndex", "Signup", new { dealerId =     Model.DealerId });
Html.UI().PageHeader.AddBreadcrumb("Cart", "PackageCartIndex", "Signup", new { dealerId =  Model.DealerId, orderId = Model.OrderId });
}
@using (Html.BeginForm("OrderItemTargetingInfo", "Signup", FormMethod.Post, new { @class = "form-horizontal" }))
{
@Html.UI().RenderPageHeader()

@Html.DisplayFor(m => m.TargetingAreaOrderItems)
<div class="col-sm-12">
    <div class="pull-right">
        <input id="Submit" type="submit" value="Submit" class="btn btn-primary" />
    </div>
</div>
}

Inside DisplayFor Template

@model SimplifiedAdvertising.Web.Models.SignupModels.TargetingAreaViewModel
<div class="row">
<div class="col-sm-12">
    <div class="col-sm-12 btn-primary" style="margin-bottom: 10px; margin-top: 10px;">
        @Html.Label(Model.MediaTypeDesc, new { @style = "font-weight: bold; padding-top: 10px; font-size: 18px;" })
        @Html.HiddenFor(m => m.OrderItemId)
    </div>
</div>
</div>
<br />
<div class="row">
<div class="col-sm-12">
    @Html.EditorFor(m => m.TargetingAreaItems, new { OrderItemId = Model.OrderItemId })
</div>
</div>

This is NULL here.

@Html.EditorFor(m => m.TargetingAreaItems, new { OrderItemId = Model.OrderItemId })

To make sure the model has data, when I just test this with @Model.TargetingAreaItems.Count() on the View where I have DisplayFor, then I get the count. But once I try to use this inside a displaytemplate view, then the model is NULL. Let me know if this is even possible to use EditorFortemplate inside a DisplayForTemplate.

I posted a question on how to share variables across actions in same controller. I found this Q/A that answered my question mostly but still left a pending question raised in this submission. Here is the link for the Q/A I found that might help someone else: Same instance variable for all actions of a controller

Here is the link for my initial question which I answered with the link above: In Rails4 How to assign variables in one controller action and use the value of it in another controller action

Now that I know I can use the before_filter and create a private action that can then be referenced from the various actions in the controller which appears to be great for known constant variables, how do I set it up in my specific case where the values change based on user action and are defined in the user interactive action?

I have a method called 'evaluate_media'. This method allows the user to select a file from various directory paths and then runs media info on the selected video file and parses the xml for certain attributes (like bitrate, aspect_ratio) and assigns the values to variables in the action. Is there any way I can share the looked up and assigned variables in this action with the other actions like the common_components without it being private and just for variable assignment? Can you please show me an example of how to do this? I did try the before_filter as so and it doesn't even call the insert. It just refreshes the page. before_filter :evaluate_media, :only => [:save_file]

Just as a refresher from my first question, After I gather this information in my evaluate_media action, I have a save button that calls the save_file method that will store this information gathered in the evaluate_media action.

Here are the 2 defined methods:

def save_file    

        src_location = @radio_button_value
        directory = "#{@dir_path_choice}"
        full_path = @filepathname
        full_filename = "#{@filepath}"
        alias_code = "#{@file_alias}"
        validate_status = "#{@file_status}" 
        error_msg = "#{@file_msg}"
        video_alias_match = "#{@msg_dtl1}" 
        audio_alias_match = "#{@msg_dtl2}" 
        video_format = "#{@video_format}" 
        video_bitrate = "#{@video_bitrate}" 
        video_width = "#{@video_width}"
        video_height = "#{@video_height}" 
        video_framerate = "#{@video_framerate}" 
        video_aspect_ratio = "#{@video_aspectratio}" 
        video_scan_type = "#{@video_scantype}"
        video_scan_order = "#{@video_scanorder}" 

        @file_alias_tfile = FileAliasTfile.new( :src_location => src_location, :directory => directory, :full_path => full_path, :full_filename => full_filename, :file_ext => '', 
                                                      :assigned_status => 'Unassigned', :file_status => 'Saved', :alias_code => alias_code, :validate_status => validate_status, :error_msg => error_msg, 
                                                      :video_alias_match => video_alias_match, :audio_alias_match => audio_alias_match, :video_format => video_format, :video_bitrate => video_bitrate, 
                                                      :video_width => video_width, :video_height => video_height, :video_framerate => video_framerate, :video_aspect_ratio => video_aspect_ratio, 
                                                      :video_scan_type => video_scan_type, :video_scan_order => video_scan_order, :video_alias_code => '', :audio_alias_code => '', 
                                                      :bus_prod_initiative_id => 0, :status => 'Active', :start_date => DateTime.now.to_date, :end_date => '', :deleted_b => 0, 
                                                      :created_by => 'admin', :updated_by => 'admin')


    if @file_alias_tfile.save
      redirect_to mainpages_home_path, :notice => "The file alias validation has been saved."
    else
      redirect_to alias_mainpages_home_path, :notice => "The file alias validation has not been saved."
    end
  end

 def evaluate_media

     @state = 'post'
     @radio_button_value = params[:location]

     @stored_file = FileAliasTfile.where(:full_path => params[:filepath2], :deleted_b => 0).first

     if @stored_file.present?
        @file_exists_flag = 'Y'
        @file_exists_msg = 'This File and Alias has been saved in application.'
     else
        @file_exists_flag = 'N'
        @file_exists_msg = 'This File and Alias has NOT been saved in application yet.'
      end

          root_dir = '/watchfolder/miniprod/hot/'
          provider_dir = ""

       @selected_filepath = params[:filepath2]
       @filepath = params[:filepath2]

       @media_xml = ::MediaInfo.call(@filepath)  
       @alias_xml = ::AliasGenerator.call(@media_xml)

       @media_xml_for = ""
       @alias_xml_for = ""
       REXML::Document.new(@media_xml).write(@media_xml_for, 1)
       REXML::Document.new(@alias_xml).write(@alias_xml_for, 1)
       alias_parse_doc = ""
       media_parse_doc = ""
       alias_parse_doc = REXML::Document.new(@alias_xml)  
       media_parse_doc = REXML::Document.new(@media_xml) 


       #parse Alias XML Doc   
       @aliasgen_ver = REXML::XPath.each(alias_parse_doc, "/aliasGenerator vr=/text()") { |element| element }    
       @file_alias = REXML::XPath.each(alias_parse_doc, "*//alias/text()") { |element| element }
       @file_status = REXML::XPath.each(alias_parse_doc, "*//error/text()") { |element| element }
       @file_msg = REXML::XPath.each(alias_parse_doc, "*//error_m/text()") { |element| element }
       @msg_dtl1 = REXML::XPath.each(alias_parse_doc, "*//closestvideoalias/text()") { |element| element }
       @msg_dtl2 = REXML::XPath.each(alias_parse_doc, "*//closestaudioalias/text()") { |element| element }

       #parse Video Media Info XML Doc  
        @filepathname = REXML::XPath.each(media_parse_doc, "*//Complete_name/text()") { |element| element }  
        @video_format = REXML::XPath.each(media_parse_doc, "//track[@type='Video']/Format/text()") { |element| element }
        @video_bitrate = REXML::XPath.each(media_parse_doc, "//track[@type='Video']/Bit_rate/text()") { |element| element }  
        @video_width = REXML::XPath.each(media_parse_doc, "//track[@type='Video']/Width/text()") { |element| element } 
        @video_height = REXML::XPath.each(media_parse_doc, "//track[@type='Video']/Height/text()") { |element| element }
        @video_aspectratio = REXML::XPath.each(media_parse_doc, "//track[@type='Video']/Display_aspect_ratio/text()") { |element| element } 
        @video_framerate = REXML::XPath.each(media_parse_doc, "//track[@type='Video']/Frame_rate/text()") { |element| element } 
        @video_scantype = REXML::XPath.each(media_parse_doc, "//track[@type='Video']/Scan_type/text()") { |element| element } 
        @video_scanorder = REXML::XPath.each(media_parse_doc, "//track[@type='Video']/Scan_order/text()") { |element| element }   

       render :action => :index
   end

I had previously used an umbraco package to pull in tagged related content in v4. This XSLT based macro will not run with v7.

For example, I need page_A to be supplemented by case_Study_A & case_study_B because the subject matter (tags) match.

Can anyone point me in the right direction with regards a razor macro that lists pages or elements within by virtue of a matching tag to the current page?

Many thanks in advance.

I have the following DropDownList on a View Layout page that displays languages from an SQL database. I want the selected item of the dropdownlist to be the page current culture (originalCulture). How can I accomplish that?

For example if the page current culture (originalCulture="en") is equal to (item.language_UI="en") then the DDL selected item should be English (item.language). I know that it's easy but I'm not familiar with Razor codes. Can someone help?

@{
var db = Database.Open("DefaultConnection");
var listLanguage = "SELECT language, language_UI FROM Languages";
var originalCulture = Convert.ToString(System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName);

List<SelectListItem> languagedropdownlistdata = new List<SelectListItem>();
bool isSelected = false;
foreach (var item in db.Query(listLanguage))
{
    languagedropdownlistdata.Add(new SelectListItem
    {
        Text = item.language,
        Value = item.language_UI,
        Selected = isSelected
    });
}

}

And here is the DropDownList on the content page:

@Html.DropDownList("lang", languagedropdownlistdata
<input type="submit" value="Select" />

I'm here to ask about a good starting point for learning ASP.NET MVC5.

If anyone has a link for tutorial please share it with me.

Thanks in advance.

I'm using ASP.NET MVC with Razor C# and I have implemented a main menu appearing on every page through _Layout.cshtml.

One of the pages linked to this menu opens a page that includes a secondary menu. This page with the secondary menu links to several different pages which are navigated via the same secondary menu.

I've used Partial views to hold each secondary menu page, and I'm wondering what is the easiest/preferred way to output these partial pages via the page with the secondary menu? (Or perhaps I shouldn't even be using Partial views to save having to add the secondary menu to each page).

Thanks.

I know I am able to add a class to a @Html.Actionlink by using, which acts on a single Actionlink at a time:

@Html.ActionLink("Add", 
                 "UpdateNote", 
                 "Notes", 
                 new { id = 0, type = (int)THOS.Utilities.Enumerations.Enumerations.Note.RelatedApplicationType.Law, appid = ((ObjectModelLibrary.Law)ViewData["currentLaw"]).LawID, baseappid = ((ObjectModelLibrary.Law)ViewData["currentLaw"]).LawID }
                 new { @class = "btn btn-primary icon-edit"},
                 null)

However,


Is there a way of defining a class (much like adding a style to all divs in the css file like:

div{
color: red;
}

^ ^
| |
this way will act on *all* divs

instead of going

 <div class="myClass"></div>

I can just write:

<div></div>

which will automatically have color:red included


would there be a way of defining a class for an ActionLink without going to each actionlink and typing @Class="myClass"


For Example


for adding styling for all button instances:

input[type="button"]{

background-color:red;
}

Can i do this with something like:

input[type="actionlink"]{

//styles for all actionlinks in project
}

and so all actionlinks can be written as:

@Html.ActionLink("Action","Controller")

and automatically include the styling stated in my css file?


I would do this the first way, but i've already ~100 made without defining a class, and don't fancy copy and pasting:

class="myClass" 

I have some text being sent from my angular controller to my view that I wish to display as formatted text, and not as HTML.. for the sake of this example, I will use the following code which outputs a read-only textarea but displays the html tags instead of formatting.

<div class="well" ng-repeat="field in model.viewFields">
    {{field.Name}} 
    <textarea disabled="true" style="height: 200px; width: 100%; resize: none">{{field.Value}}</textarea>
</div>

What can I swap the textarea with to show my {{field.Value}} html as formatted text?

I have accidentally deleted the razor web.config file in my Asp.Net MVC 5 project. Is it possible to regenerate it?

I have an MVC 5 app, and in my _Layout.cshtml file, I have two input fields and a href attribute, and when the user fills them, and presses the href, I want to redirect to a particular view in my app, which contains a form with a few fields, and for the two of the fields, I want to assign the values passed by the input fields in my _Layout.cshtml file, and then let the user fill out the rest of the fields. I have this in my Layout:

<div class="input-top">
     <a class="GoBtn" href=""><img src="~/Content/img/GOBtn.png" class="gobtn-position"></a>
     <input id="homeZipCode" type="text" class="form-control input-position-2" placeholder="ZIP">
     <input id="homeService" type="text" class="form-control input-position-1" placeholder="What do you need done today?">
</div>

Then, I have those two action methods in my controller:

    [Authorize]
    public ActionResult ServiceRequest()
    {
            ViewBag.StateID = new SelectList(db.States, "StateID", "StateName");
            return View();
    }

    [Authorize]
    [HttpPost]
    public ActionResult ServiceRequest(RequestViewModel rvm, HttpPostedFileBase image = null, HttpPostedFileBase video = null)
    {
       ...
    }

So, I don't want to post directly from the AJAX call, but I want to open the view, and assign the values from my input fields in Layout. I guess therefore, I need to call the get method, not the post one. I have something like this in my _Layout.cshtml, but it doesn't seem to work.

<script>

$(document).ready(function () {
    $('a.GoBtn').on('click', function (e) {

        e.preventDefault();

        var homeZipCode = $("#homeZipCode").val();
        var homeService = $("#homeService").val();

        var model = { ZipCode: homeZipCode, ServiceName: homeService };

        $.ajax({
            url: '@Url.Action("ServiceRequest", "Home")',
            contentType: 'application/json; charset=utf-8',
            type: 'GET',
            dataType: 'html',
            data: JSON.stringify(model)
        })
            .success(function (result) {
            });
    });
});

The point is that, when I check the network tab in developer tools, I see that as a response I get my ServiceRequest page, but it shows it as empty, and also my view is not redirected. I just get 200 status but nothing special happens. Below you can find part of my ServiceRequest view:

@using (Html.BeginForm("ServiceRequest", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
                {
                    @Html.AntiForgeryToken()

                    <div class="form-horizontal">
                        <h4>Request</h4>
                        <hr />

                        <div class="form-group">
                            @Html.LabelFor(model => model.StateID, "State", htmlAttributes: new { @class = "control-label col-md-2" })
                            <div class="col-md-10">
                                @Html.DropDownList("StateID", null, "Please select a state", htmlAttributes: new { @class = "form-control" })
                                @Html.ValidationMessageFor(model => model.StateID, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.ZipCode, "Zip", htmlAttributes: new { @class = "control-label col-md-2" })
                            <div class="col-md-10">
                                @Html.EditorFor(model => model.ZipCode, new { htmlAttributes = new { @class = "form-control", @id = "service-manual" } })
                                @Html.ValidationMessageFor(model => model.ZipCode, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        <div class="form-group">
                            @Html.LabelFor(model => model.ServiceName, "Service", htmlAttributes: new { @class = "control-label col-md-2" })
                            <div class="col-md-10">
                                @Html.EditorFor(model => model.ServiceName, new { htmlAttributes = new { @class = "form-control", @id = "service-manual" } })
                                @Html.ValidationMessageFor(model => model.ServiceName, "", new { @class = "text-danger" })
                            </div>
                        </div>

                        // more fields below

Simply, I want after my AJAX call to open that view and for the ZipCode and ServiceName parts, to get the values of the input fields in my Layout. The other fields should be blanks. Any idea how to achieve it?

A while back I found this interesting little trick here: Assign JavaScript variable value to ASP.Net Session variable using JQuery AJAX

It embeds a C# WebMethod in an .aspx form and then calls it through ajax. Is there a similar technique that can be applied to a razor form? Can razor forms even be used that way? Or tricked in a similar way as a controller? I experimented a little with no luck, so looking for suggestions on something I might have missed.

To be clear: is it possible to embed C# code in a razor page and then call that code from that page, as in the example, above.

I am trying to run my MVC application based on ASP.Net with the MVC 4 technology and the EntityFramework.

public ActionResult Test()
{
    DbEntities entities = new DbEntities();
    ViewBag.AddressBookList = entities.ADDRESSBOOK.Take(100).ToList();
    return View();
}

The problem is that I'm getting this exception when I'm calling /Home/Test. It must be caused by the EntityFramework because the whole application works except to the point when I'm trying to retrieve data of the database with the EntityFramework. When I test it within Visual Studio (IIS) it runs properly without any error.

System Informations

  • Windows
  • Net Framework 4.0
  • ASP .Net MVC 4
  • EntityFramework 6
  • Mono 3.2.3 (newest Windows version)
  • nginx FastCGI with fastcgi-mono-server4

System.UriFormatException

Invalid URI: The format of the URI could not be determined: System.Data.Resources.SqlClient.SqlProviderServices.ProviderManifest.xml

Stacktrace

at System.Uri..ctor (System.String uriString, Boolean dontEscape) [0x00000] in <filename unknown>:0
at System.Uri..ctor (System.String uriString) [0x00000] in <filename unknown>:0
at Mono.Xml.Schema.XmlSchemaValidatingReader..ctor (System.Xml.XmlReader reader, System.Xml.XmlReaderSettings settings) [0x00000] in <filename unknown>:0
at System.Xml.XmlReader.CreateValidatingXmlReader (System.Xml.XmlReader reader, System.Xml.XmlReaderSettings settings) [0x00000] in <filename unknown>:0
at System.Xml.XmlReader.CreateFilteredXmlReader (System.Xml.XmlReader reader, System.Xml.XmlReaderSettings settings) [0x00000] in <filename unknown>:0
at System.Xml.XmlReader.Create (System.Xml.XmlReader reader, System.Xml.XmlReaderSettings settings) [0x00000] in <filename unknown>:0
at System.Data.Entity.Core.SchemaObjectModel.Schema.Parse (System.Xml.XmlReader sourceReader, System.String sourceLocation) [0x00000] in <filename unknown>:0
at System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate (IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, System.Data.Entity.Core.SchemaObjectModel.AttributeValueNotification providerNotification, System.Data.Entity.Core.SchemaObjectModel.AttributeValueNotification providerManifestTokenNotification, System.Data.Entity.Core.SchemaObjectModel.ProviderManifestNeeded providerManifestNeeded, IList`1& schemaCollection) [0x00000] in <filename unknown>:0
at System.Data.Entity.Core.SchemaObjectModel.SchemaManager.ParseAndValidate (IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, SchemaDataModelOption dataModel, System.Data.Entity.Core.Common.DbProviderManifest providerManifest, IList`1& schemaCollection) [0x00000] in <filename unknown>:0
at System.Data.Entity.Core.SchemaObjectModel.SchemaManager.LoadProviderManifest (System.Xml.XmlReader xmlReader, System.String location, Boolean checkForSystemNamespace, System.Data.Entity.Core.SchemaObjectModel.Schema& schema) [0x00000] in <filename unknown>:0
at System.Data.Entity.Core.Common.DbXmlEnabledProviderManifest.Load (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0
at System.Data.Entity.Core.Common.DbXmlEnabledProviderManifest..ctor (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0
at System.Data.Entity.SqlServer.SqlProviderManifest..ctor (System.String manifestToken) [0x00000] in <filename unknown>:0
at System.Data.Entity.SqlServer.SqlProviderServices.GetDbProviderManifest (System.String versionHint) [0x00000] in <filename unknown>:0
at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifest (System.String manifestToken) [0x00000] in <filename unknown>:0 

I've got an example project. There is a config class which I need to set my id and key.

public class Config
    {
        #region Fields
        private static string partner = "";
        private static string key = "";
        #endregion

        static Config()
        {
            //↓↓↓↓↓↓↓↓↓↓ Config your identity ↓↓↓↓↓↓↓↓

            //PartnerID (Begins with digits 2088)
            partner = "";

            //Veryfy Code 
            key = "";

            //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
        }

        #region Properties

        public static string Partner
        {
            get { return partner; }
            set { partner = value; }
        }

        public static string Key
        {
            get { return key; }
            set { key = value; }
        }
        #endregion
    }

So methods in other class can get my ID and Key like:

string _partner = Config.Partner.Trim();
string _key = Config.Key.Trim();
public bool Verify(SortedDictionary<string, string> inputPara, string notify_id, string _partner, string _key )
{
  //...
}

My question is, what if I change the Config.cs as:

public class testConfig
    {
        public const string Partner = ""; //Config your PartnerId
        public const string Key = ""; //Config your Key
    }

Since my partnerID, Key never change if everything goes well, and they only need to be compiled at the very beginning so that method in other class can get these two value. Calling Config.Key.Trim(), the results are the same. Why not use a class filled with const fields like I just write?

Suppose there's a Photos model. For this model I have several views: recent photos, popular photos, favourite photo etc.. How do I go about creating the controller for this model. There are different options:

  1. One PhotosController with an index action. I send a parameter to the index action and based on this parameter the controller makes a query to the DB and returns @photos to the view. This has the disadvantage that the index action will become quite big.

  2. Same as above but logic for deciding what query to make is extracted into a service, so that the controller stays lean.

  3. One PhotosController with several actions recent, popular, favorite etc., but that's not very restful.

  4. Several controllers with index actions - RecentPhotosController, PopularPhotosController etc.. In that case though I must still have a normal PhotosController to hande show, edit actions.

Is there an established best practice for this and what are the considerations when choosing one of those options?

I am trying to update values in table emp. Which column to update is dynamic.

public void updateEmployees(List<String> columnDb, List<String> columnValues)
{
   var data = ctx.tblEmployee.Where(e => e.Id == empId).Select(e => e).SingleOrDefault();
   ....

   data.columnDb = columnValues; // Pseudo       

   ctx.tblEmployee.Add(data);
   ctx.SaveChanges();
}

How to update columns which are passes dynamically as a parameter?