asp.net-mvc

What is the proper way to handle forms in ASP.NET MVC?

Forms + ASP.NET MVC = Confusing for me: What are the preferred ways to setup your controller action for form posts? Do I need to specify an attribute that has [AcceptVerbs(HttpVerbs.Post)]? Should the controller action take a "FormCollection" or should I use ModelBinders? If I should use ModelBinders, how? How do I setup the f...

How are you handling the deletion of an item with the new complex binding syntax?

Many of you may have noticed that since RC1 you don't have to include the .Index hidden field to enable complex model binding. However one of the drawbacks is that now you have to have the index starting from 0 and it cannot break. eg. skip from 4 to 6 etc. With the old syntax I was able to just remove the item from the DOM and when th...

Is there an automatic way in ASP.NET to tell which resources are not used anywhere in code and markup?

I believe lots of us have been presented with a challenge to check manually through hundreds of string constants to check which ones are used and which are not (orphans). Although I do not have that many yet in my current project, I still find it difficult already to do a code review and check for dropped constants manually. Is there an...

Can "Add View..." in MVC.NET ignore a property when creating a strongly-typed View?

Can the "Add View..." wizard in ASP.NET MVC ignore a property in my Model when creating a strongly-typed View? I select "Create" as the "View Content" in the wizard and want certain properties in my Model to be ignored. I want to quickly create and delete Views while prototyping, and I don't want to manually edit a View that I'll only ...

Why doesn't this form call my controller action in ASP.NET MVC?

I'm attempting to make a TinyURL clone in ASP.NET MVC as a learning project. Right now, all I want is to be able to submit new URLs to my /Home/Create action via a form. I have my LINQ expression all setup, I have my routing setup, and I have my view setup but something is wrong with my setup. Routing: routes.MapRoute( ...

MVC - How to use an anchor tag to submit when using Html.BeginForm?

Hi, The subject says it all. The BeginForm does not have a way of giving the form name so that I can do this <A HREF="JAVASCRIPT:Form1.submit()">Next</A> This fails because no Form1???? Malcolm ...

Implementing pager through WCF service

I am developing an application which includes a WCF service and its ASP.NET MVC client. The ASP.NET MVC website must display a grid of objects - say, products. These products are stored in database which is accessible through the WCF service. So somewhere inside an MVC controller I call WCF service's method that returns me an array of p...

international characters in url, mvc filtering problem

Hi guys, I have a problem with filtering in asp.net mvc. I have a page with listed collection and the filter. Filter has values for filtering collection, it is: category, status and the containing string. The problem is in internationalisation-application can be on more than one language, so the containing string can be special characte...

Change the default model binder in asp.net MVC

Is there any way I can set the default ModelBinder to one of my own? ...

Preventing Url manipulation attacks with MVC?

Any good strategies, code snippets etc for preventing URL manipulation? For example I have this url; http://localhost/profile/edit/5 the id could easily be changed to anything and thus people could edit profiles they are not supposed too. Here are a few ideas I thought of but they all have there drawbacks: Change my system to use GUI...

Passing a method to another method

Is it somehow possible to send a function to another function for it to run. For instance...I want to have an attribute on a field where I can specify a method that will be sent to another method where the method passed in will be run. Not sure if that makes any sense but here's a small example. [ValidateIf(x=>x.test())] public string ...

Mocking the FormsAuthentication.Authenticate() method

Is there any way I can mock FormsAuthentication.Authenticate("username", "password") method with test credential? My test goal is to make sure that if authentication fails, it redirects to correct place. I'm using Rhino Mocks as mocking framework. Thank you very much for your help, ...

How to get input value or javascript variable in Asp.Net MVC Ajax.ActionLink

I want to pass an input control value (say textbox1.value or a javascript variable) to a controller action method (as a parameter) without a form post (using Ajax.ActionLink). please see the code below is it possible to assign like new {name = textbox1.value} in Ajax.ActionLink. View <input type="text" id="textbox1" /> <% =Ajax.Action...

Advice on playing sound files from an ASP.NET MVC app

I'm working on a new ASP.NET MVC / JQuery app which will need to play short sound files in response to user actions. For example, in some cases, when a user clicks on a word, the computer should pronounce that word (there is a small finite list of words). I'd like advice on the following: Which sound file format(s) would you recomme...

Anything more secure than hidden form fields in ASP.NET MVC?

In ASP.NET MVC (default routing), I'd like to use a URL like this to return a View with a form to edit a customer: /Customers/Edit/5 I need to make use of CustomerId=5, but I don't want to permit a customer to change it. Right now I make the id hidden using: <%= Html.Hidden("CustomerId") %> This accomplishes what I want, but I'm und...

How to handle paging in asp.net mvc?

I'm using asp.net mvc. I want to add paging to the list of records. Please help with any links or sample code. Thanks. ...

How may I best use the [Authorize] attribute with Ajax and Partial Views?

I was about to use [Authorize] on Actions that return partial views through Ajax; but I'm not getting the behavior I'd like (although its the behavior I expected). It seems like a long shot; but, is there any way to extend this attribute to "break out" of an AJAX call and redirect the entire page to the login screen? (As opposed to retu...

ASP.NET MVC

Im adding one new route to RouteCollection like this routes.Add(new Route("{*data}", new MyRoutehandler())); now how to specify the controller name and action name inside this MyRouteHandler( my own route handler ) ...

ASP.NET MVC Dynamic Routing

How to change the default Action name inside the ProcessRequest(HttpContextBase) method.. ...

ControllerActionInvoker

What is the use of ControllerActionInvoker class? ...