asp.net-mvc

ASP.NET MVC- submitting a client side created collection

I am using javascript to append user selections to a list. When user is done , which is the best way to go: 1: create index for the list and submit as model in a form to the controller? 2: create hidden element and use javascript to append values and submit as actionlink? (not sure how to tell actionlink the value here) 3: wrap form b...

ASP.Net MVC: "The given key was not present in the dictionary"

I have a set of websites built in MVC - each, essentially, is a clone of one original site). On one of the sites I'm getting the error from the title of this post ("The given key was not present in the dictionary") - it only occurs on a single page. The code is identical across all of the sites including the one which is acting up. Each ...

How best to work with the Expires header in ASP.NET MVC?

I want to be able to set a long expires time for certain items that a user downloads via GET request. I want to say 'this is good for 10 minutes' (i.e. I want to set an Expires header for +10 minutes). The requests are fragments of HTML that are being displayed in the page via AJAX and they're good for the user's session. I don't want t...

Entity Framework + SQLite deployment

Hi, I have a ASP.NET MVC app that is using SQLite database through Entity Framework. Everything works on VS 2008's local development webserver. However, deploying the web app to my service provider causes this error: [ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.] System.Dat...

How do I use Windsor to inject dependencies into ActionFilterAttributes

Having seen how NInject can do it and AutoFac can do it I'm trying to figure out how to inject dependencies into MVC ActionFilters using Castle Windsor At the moment I'm using an ugly static IoC helper class to resolve dependencies from the constructor code like this: public class MyFilterAttribute : ActionFilterAttribute { priva...

Binding an Enum to LINQ and SelectListItem

Hello. I'm trying to bind the following enum public enum CertificateTypes : byte { None = 0, Original = 1, AuthenticatedCopy = 2, Numbered = 3 } to a tinyint column on the database. However, when creating the SelectListItems and calling, for instance, Person.CertificateTypes.Original.ToString() I get this: <option va...

Custom ASP.NET MVC 404 Error Page

I am trying to make a custom HTTP 404 error page when someone types in a URL that doesn't invoke a valid action or controller in ASP.NET MVC Instead of it displaying the generic Resource Not Found ASP.NET error I don't want to use the web config to handle this... Is there any kind of routing magic I can do to catch any invalid urls? ...

In MVC, how do I return a string result?

Hi, In my ajax call, I want to return a string value back to the calling page. Do I still using ActionResult or just return a string? ...

asp.net mvc Adding to the AUTHORIZE attribute

How do I create a custom attribute to extend existing Authorize attribute in MVC? ...

IIS 6 Configuration interfering with ASP.NET MVC RC1

I am using Netegrity's SiteMinder single sign on for a subset part of my development machine. Something like https://testdev.com/sm/testapp where /sm is my SiteMinder configured location. However, when I run ASP.NET MVC apps in a virtual directory under the /sm folder I get some unexpected results from Url.RouteUrl or Html.BeginRouteFor...

How do you browse files on the Server in ASP.NET MVC?

I'm very new to ASP.NET MVC, but even more than that, I'm very new to web development in general. What I want to do is simple. I have a folder in my MVC project called /Content/Images where I have some images. I'd like for my controller to grab all the images in this folder, and send them to the view. The view will then render these imag...

How do I add a custom item to the top of a dropdown using the asp.net mvc Html.DropDownList helper?

I have a dropdown list on my asp.net mvc site: <%= Html.DropDownList("CustCodes") %> My controller: ICallService sc = new CallService(); IList<CustCode> custCodes = sc.GetCustCodes(); ViewData["CustCodes"] = new SelectList(custCodes, "ID", "Name"); What I want is once the dropdown is displayed to either have a blank entry at...

How do I secure my JsonResult GET calls?

I know how to use MVC's AntiForgeryToken attribute and it's associated HTML helper to help XSRF-secure my application's form POSTs. Can something similar can be done for JsonResults that implement GET? For instance, my View contains an onSubmit jQuery call like such: $.getJSON("/allowActivity/YesOrNo/" + someFormValue, "{}", function(...

Javascript Result to generate Jquery CRUD ajax operations

Latest Asp.Net MVC RC permits to return JavaScript ActionResult. I'd like to dynamically generate from the controller the Jquery script code associated to perform the classical $.ajax calls to the controller for Create Read Update Delete operations in ajax instead of classical get/post form actions. Should I generate the javascript code ...

ASP.NET MVC: Binding a Complex Type to a Select

Hello all, I trying to work out if there is built in support for binding complex types to form elements. To use a common hypothetical situation: I have a Product entity that belongs to a Category - the models look something like this: public class Product { public int ID { get; set; } public string Description {...

ASP.NET MVC RC1 Routing problem

I have a route table similar to this // Allow browsing categories by name, instead of by ID. routes.MapRoute("Categories", "Categories/{action}/{name}", new { controller = "Categories", action = "Index", name = "" } ); // All other pages use the default route. routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller ...

How do I create / use a MembershipProvider?

How do you create a MembershipProvider for use in an ASP.NET/MVC website? Doesn't it generate the tables it needs for you in your database? ...

Optional property on a bound object in ASP.NET MVC

I'm trying to build a "New Customer" form, so I'm using the default model binder to build my Customer object: public ActionResult New(Customer customer) { ... } The only problem is I have a few properties on the Customer object that aren't required. When I leave these fields blank, ASP.NET MVC automatically throws up model errors stat...

Getting Masterpage Name in asp.net MVC

Whats the earliest point I can programatically get to the name of the masterpage that will be used in an asp.net MVC application? The idea being changing the viewdata used depending on the master page. I want to be able to set something as early as possible so that individual developers don't need to know to populate it. Ideally it woul...

Encode dataview value in ASP.NET MVC Actionlink

I am using the Microsoft Ajax Template DataView to bind values to a template. I can do this and it works as you'd expect: <h3>{{ID}}</h3> <p>{{Address}}</p> However I am trying to build an action link that has the ID in it. <h2><%= Html.ActionLink(Html.AttributeEncode("{{Name}}"), "Index", "Restaurant", new { Id = Html.AttributeEncod...