asp.net-mvc

Unit testing my controller method results in an empty ViewName?

Hi folks, I'm doing some simple MS unit tests on my standard, nothing special controller. When i check the ViewName proprty, from the returned ViewResult object, it's "" (empty). I'm under the impression that the ViewName is implied by the name of the View (as suggested by this MS article on ASP.NET MVC controller testing). BTW, whe...

Timing an ASP.NET MVC Action

I want to try to time an ASP.NET MVC ActionMethod. I was thinking a nice way to do this would be using a custom header. Can I use an ActionFilterAttribute to do this? Has anyone done this, or is there any build in ASP.NET functionality to do this? I'm just being kicked out of Starbucks and hoping someone will have an answer before I ...

When using RedirectToAction, routeValue losing reference properties.

So if i do this in the first controller: public class AController:Controller { public ActionResult ActionOne() { MyObject myObj = new MyObject() myObj.Name="Jeff Attwood"; myObj.Age =60; myObj.Address = new Address(40,"Street"); ...

How to I test an HTTP-Post with Moq in ASP.NET?

Hi folks, i've got the following Action Method I'm trying to moq test. Notice the AcceptVerbs? I need to make sure i'm testing that. here's the method. [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create([Bind(Include = "Subject, Content")]Post post, HttpPostedFileBase imageFileName) { ... } here's the moq code i have... ...

How to self-redirect and changing a parameter in asp.net mvc?

If my urls looks like: www.mysite.com/1/home www.mysite.com/1/other-action www.mysite.com/1/another-action/?value=a how can I switch the 1 parameter while invoking the same action with the same parameters and querystring values? For example if I'm currently browsing www.mysite.com/1/another-action/?value=a I would like to obtain the ne...

RenderAction RenderPartial

From what I have understood there is a big difference between the Html.RenderPartial included in the ASP.NET MVC release and the HTML.RenderAction in the Microsoft.Web.Mvc.ViewExtensions included in MVC Futures. On my application I have many pages composed from many "widgets" (sort of) each having its own specific function. It seemed...

MVC Gobal error handling: Application_Error not firing

I am attempting to implement gobal error handeling, in my MVC application. I have some logic inside my Application_Error that redirects to an ErrorController, but its not working. I have a break point inside my Application_Error method in the the Global.aspx. When I force an exception the break point is not being hit. Any idea why? ...

Updating ModelState with model object

The problem: How to update ModelState in posting+validation scenario. I've got a simple form: <%= Html.ValidationSummary() %> <% using(Html.BeginForm())%> <%{ %> <%=Html.TextBox("m.Value") %> <input type="submit" /> <%} %> When user submits I want to validate input and in some circumstances I want to fix the error for user, l...

Custom Controller Factory, Dependency Injection / Structuremap problems with ASP.NET MVC

I recently tried to implement dependency injection using StructureMap. I managed to follow the example all the way but I'm encountering a thrown exception every time I try to run the application. Here's some code snippets from my controller factory. public class StructureMapControllerFactory : DefaultControllerFactory { protected ov...

suggestions on familarizing self with .NET MVC

I've been reading a lot about .NET's step into the MVC framework. I've tried the example applications too. However, I've been a java programmer for a while. So without having any knowledge of c# it gets difficult to understand the MVC applications. What would you guys suggest is the best resource to get up and running with c# and t...

The SessionStateTempDataProvider requires SessionState to be enabled.

My hybrid (web forms/MVC) project is working fine in my local development environment BUT when I deploy (xcopy) to my Test environment I get the error that SessionState is needed (full error shown below). What's strange about this error message is that session state is set as InProc in my web.config and IIS7 configuration shows it as as...

how to access new manuplated combined columns in MVC asp.net using linq

Hi, I am facing problem in displaying the column field value at the view. I am returning view like follows. var TicketList = (from T in db.Tickets where T.Title.Contains("a") select new { customerName = ( from cname in db.Customers ...

Is it possible to unit test some AddModelError results in ASP.NET MVC?

Hi folks, i've got a controller method which returns a RedirectToActionResult (sucess!) or a ViewResult (failed with error messages). If the business logic fails, i add the error messages to the AddModelError property. Is there any way i can test this in my MS Unit tests? I also have moq, if that helps too. (i don't believe moq is r...

Web Site Administration Tool Not Working with ASP.NET MVC

I'm just starting with ASP.NET MVC and I was trying the Authentication with this new architecture. So, I started following a tutorial in the official site and, while I was trying to add some users through the Web Site Administration Tool, I found this error: There is a problem with your selected data store. This can be caused by an i...

System.Web.Abstractions: what is it good for?

... absolutely nothing? What part of the puzzle does it fill for ASP.NET WebForms and ASP.NET MVC respectively? Can you somehow create a ASP.NET * base-application which uses System.Web.Abstractions so it can be used in both kinds of ASP.NET-web applications? In that case, how did they retro-fit the classes in System.Web.Abstractions ...

Installing nUnit with ASP.Net MVC 1.0

Does anyone have any advice/information on how to install nUnit with ASP.Net MVC? I have seen previous posts which related to the preview releases and involved a ghoulish nightmare of having to create template files, run command prompt and even mess with the registry. Obviously this is far from ideal and given Microsoft's intention to ...

How to provide a helpful error messsage in a ValidationSummary for invalid user input?

Scenario: A user enters a string in the DateTime field. A * appears when a postback occurs but no message in a ValidationSummary. I have tried implementing IDataErrorInfo but the code never falls through IDataErrorInfo.this[string columnName] for the EventDate field. I have tried implementing DataAnnotations attributes again this doesn'...

Forcing English language exceptions in .NET framework

Hi, While working with ASP.NET MVC, I have noticed that exception messages issued by the .NET framework installed on my System are in German. I'd really prefer English messages, so I can post them on SO. I know this has been asked before on SO, but strangely enough none of the suggested workarounds seem to work in my case. I have alre...

Upgrade MVCMembership to 1.0?

Does anyone know if there is a version of MVCMembership that works with MVC 1.0? The existing code doesn't work properly with this release. Alternatively, would anyone be willing to help upgrade the code-base? (edit to draw out the key points) ...

ASP.Net MVC Controller Namespace array

I noticed that the MapRoute extension includes an overload that accepts a string[] parameter which is called 'namespaces'. I read what Google had for me on it, and supposedly this is to help the framework find controllers in places it wouldn't otherwise look. I did some spiking, and tried putting controllers in weird locations. I put o...