actionmethod

What clever things have you done with an ASP.NET MVC Action method

The ASP.NET MVC controller action methods are primarily used for handling 'business' operations but it can be used for lots more. I thought it would be fun to see what creative, useful things people have created actions for that may be practical or useful for others. Here's my contribution : Javascript file concatenator - to reduce nu...

How can i pass two different query string params that represent one action method param?

Hi folks, i've got an action method like the following public JsonResult Index(string version) { .. do stuff, return some data v1 or v2. Default = v2. } So, this action method returns some data, which can be formatted either as Version 1 or Version 2 (whatever output that is ... just know that they are schemantically different). ...

ASP.NET MVC - POST Action Method with Additional Parameters from URL

With ASP.net MVC is it possible to POST a form to a controller action which includes parameters not in the form, but from the URL? For example The Action method in GroupController: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(int idOne, int idTwo, Model model) { ... } The route: "{controller}/{action}/{idOne...

ASP.NET MVC AuthorizeAttribute passing values to ActionMethod?

Hi everyone I'm only a newcomer to ASP.NET MVC and am not sure how to achieve a certain task the "right way". Essentially, I store the logged in userId in HttpContext.User.Identity and have written an EnhancedAuthorizeAttribute to perform some custom authorization. In the overriden OnAuthorization method, my domain model hits the data...

How to attach a description to each ActionMethod in a Controller (ASP.net MVC)?

So recently, I came up with a way to dynamically build a nav-bar menu where the Controller (And its Index ActionMethod) would be listed in a horizontal bar at the top of each page (via Site.Master) but also based on the user's assigned roles. Each Controller listed would also list (in a vertical drop-down) the ActionMethods available to ...

Is it better to return the most specific or most general type from an action method?

What are the benefits or detriments of either? ...

Default value for parameter in Controller Method is overriding everything

Hello i have just started learning mvc2 and im having a problem with the default value for the parameter page(you can see the method below). Its always 0 regardless of what i type in the URL. For example this h.ttp://localhost:52634/Products/List/2 should show page 2 but when in debug mode the page parameter is 0, so im always gettin...

Why is this View Model being populated when I pass "" into RenderAction?

I'm trying to implement a Widget control that exists on every page in the system, which will allow the user to have basic Search & Directory functionality available on each page. This is a tab control defined below, where in the <ul> the currently selected tab is determined by the the value in Model.CurrentTab and the corresponding conte...

Is this a 'hack', and if so is there a better way to determine which ActionResult to return?

I have an A - Z directory 'widget' that I have on every page. If the user is on the home page and they click something in the directory, I want to load up the directory page with the corresponding result loaded. But if the user is on the directory page and they click something, I want to asynchronously load the result without doing a pag...