asp.net-mvc

MVC Routing - Tagging model items to specific routes

Hi, Just wondering if anyone has advice on tagging items to specific routes. For example, if I have 2 items, they're of the same model type however I want one of the items to have a route. "folder1/folder2/{ItemName}" and the other to have a route "folder3/folder4/{ItemName}" So I want to specify that item one is only viewable thr...

dotnetopenauth token ? is it required?

Hi, I've implementend openId login system on my site and it works ok, but when i compare what is send to openidprovider and back is different with that what is send by stackoverflow.com for example whis send s paramenter and token parameter? Are these parameteres custom parameters send by stackoverflow or dotnetopenid can sand them but y...

Query string with slashes "/" not working in asp.net mvc?

Hello guys, I have a special case here: My action method accepts one parameter, this parameter is expected to be a full url (e.g. http://www.somesite.com/article/onesite?hello=whatever&etc=blah). When working with old asp.net (oh, excuse me guys, I mean web forms) this works just fine, but when using asp.net mvc and preparing the r...

ASP.Net MVC - Merge model and formcollection into object to pass to a View

I have a website that uses one Action method which passes a pagename to the get action method. In the action method it finds the model item by the pagename and returns the relevant stuff to the view. I have now created a POST action method for this because I need it in my contact page. I still need to find the model by page name and ret...

ASP.NET MVC Result Return Helper

I find myself needing to return various JSON results to the client from my controller actions. I have created static "helper" methods of the type ContentResult. I want to be able to reuse these helpers in multiple projects, so I've created them in their own class, and someday soon I'll move them to their own assembly. Here is my questio...

How do I unit test a controller action that uses ther Controller.User variable?

I have a controller action that automatically redirects to a new page if the user is already logged in (User.Identity.IsAuthenticated). What is the best way to write a unit test for this scenario to ensure that the redirect takes places? ...

asp.net mvc: simulating autopostback for simple checkbox

I have a simple checkbox, generated with: <%= Html.CheckBox("myCB" )%> How can I add an onChange handler to this that does a submit? ...

Why does firefox round-trip to the server to determine whether my files are modifed?

I have some static content on my web site that I have set up caching for (using Asp.NET MVC). According to Firebug, the first time I open the page, Firefox sends this request: GET /CoreContent/Core.css?asm=0.7.3614.34951 Host: 127.0.0.1:3916 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3...

How to do Authentication between a webservice and a mobile phone?

Hi I want to make a windows mobile 6 cellphone application. This application will talk to a web service that I want to make. I don't know must about web services and programming app for phones so I got a couple questions. How do I do authentication? Like my user loads up my app and goes to the login page. They type in there credenti...

subcontroller/partialrequest and form action method

What I need to do is the following Set small login form (or any partial view) Complete login actions Get back to the SAME place (controller/action) user was before clicking LOGIN button Any of Partial Request/Subcontroller,RenderAction solutions offer this without any extra code to handle parent page url? ...

mvc session timeout

I'm using mvc form authenticate. After session Timeout it's automatically redirecting to login page. How can I redirect to some other page? ...

asp.net mvc and linq to entities: how to include text value from IEnumerable<SelectListItem>

I have a table with a constraint on one field - it can be 1, 2 or 3. (The correct solution to this is probably to create a lookup table for this, but for now I'm wondering if it's possible to do this without the lookup table.) I've created a class that returns an IEnumerable for the values. I'm using LINQ to Entities, and would like t...

Deleting form values from cache using jQuery

I am facing this bizarre problem in my asp.net mvc application: In one page I am showing a table full of data of a model class. Each row of data has a Edit image <img src='somesrc' onclick='fnClick({mode:'edit',..other params});/>'. In addition to that I've Add button also to populate the same model class mentioned <a href='#' onclick=...

Got a "The project type is not supported by this installation" when converting MVC2 application to VS2010

I just installed Visual Studio 2010 Beta 2 on my hard drive. I also reinstalled MVC Beta 2. I opened then my solution in VS2010 and I got the error message "The project type is not supported by this installation". I don't really understand since, first I upgraded from MVC1 to MVC2 in Visual Studio 2008 and today I tried to convert it to...

Using ASP.NET MVC SubControllers with action parameters?

I am experimenting with MvcContrib subcontrollers. Looking at the example in the source, your parent controller (HomeController) takes an action which takes the subcontroller (FirstLevelSubController) as a parameter: public class HomeController : Controller { public ActionResult Index(FirstLevelSubController firstLevel) { ...

How to use another error page instead of Error.aspx in ASP.NET MVC?

Hi, I have AdminError.aspx and Error.aspx pages and I want to display AdminError.aspx when there is an exception. I need both files. Why this doesn't work? <customErrors mode="On" redirectMode="ResponseRedirect" defaultRedirect="AdminError.aspx" /> Instead Error.aspx is always displayed. What can I do? ...

Set value for textbox in action

I have a Textbox rendered by an HtmlHelper <%= Html.TextBox("CategoryTitle",Model.CategoryTitle) %> I post to an action. In the action I manually change the value for CategoryTitle and need to display this new value to the user, but the original value from the post is taken. public ActionResult Textboxer(CategoryViewModel model) {...

Using ValidateAntiForgeryToken with Ajax.ActionLink

Is it possible to use the ValidateAntiForgeryToken attribute on a controller action when the request comes from Ajax.ActionLink (using Http Method Post?). The alternative appears to be to hand roll a JQuery Ajax request but I am curious if there is a way within the MVC Ajax framework. ...

Html.BeginForm and HTML Attributes w/o specifying Controller and Action

I like the cleanliness of using (Html.BeginForm()) And hate that adding HTML attributes requires specifying the controller, action, and form method. using (Html.BeginForm("Action", "Controller", FormMethod.Post, new { id = "inactivate-form" }) Is there a way to use Html.BeginForm and specify HTML attributes for the form without ...

MVC Views and Controllers: Re-instantiate entities when form submitted

We are working with entities in our MVC controllers which are passed to strongly typed views. How do we re-instantiate these entities in the controller with updated data when the form is posted in the view? The form does not contain all the fields of the entity so all of the data needed to re-instantiate the entities won't be there in ...