asp.net-mvc

ASP.NET MVC Preview 5 & Resharper weirdness

I've just created my first Preview 5 error and it doesn't seem to place nice with Resharper. All the C# in the Views are coming up with errors, things like <%= Html.Password("currentPassword") %> has the "currentPassword" highlighted with the following error: Argument type "System.String" is not assignable parameter type "string". IL...

silverlight vs ASP.NET MVC

I'm debating whether to use Silverlight 2.0 vs ASP.NET MVC for a web application. The web application will be a subscription free service marketing all age groups. It's important the source is highly testable, but also with the Web 2.0 movement a graphical web application is important as well for competitive reasons. I'm assuming silv...

Biggest advantage to using ASP.Net MVC vs web forms

What are some of the advantages of using one over the other? ...

Caching Data Objects when using Repository/Service Pattern and MVC

I have an MVC-based site, which is using a Repository/Service pattern for data access. The Services are written to be using in a majority of applications (console, winform, and web). Currently, the controllers communicate directly to the services. This has limited the ability to apply proper caching. I see my options as the following...

Where'd my generic ActionLink go?

Moved from preview 2 to preview 5 and now my Html.ActionLink calls are all failing. It appears that the generic version has been replaced with a non-type safe version. // used to work <li> <%= Html.ActionLink<HomeController>(c => c.Index(), "Home")%> </li> // what appears I can only do now <li> <%= Html.ActionLink<HomeController>("...

Code behind in ASP.NET MVC

What is the purpose of the code behind view file in ASP.NET MVC besides setting of the generic parameter of ViewPage ? ...

404 Http error handler in Asp.Net MVC (RC 5)

How can I Handler 404 erros without framewok throw Execption 500 error code ...

ASP.NET MVC: Making routes/URLs IIS6 and IIS7-friendly

I have an ASP.NET MVC-application which I want deployable on both IIS6 and IIS7 and as we all know, IIS6 needs the ".mvc"-naming in the URL. Will this code work to make sure it works on all IIS-versions? Without having to make special adjustments in code, global.asax or config-files for the different IIS-versions. bool usingIntegratedP...

How do you change the style of a div programatically

How do I change the style (color) of a div such as the following? "<div id=foo class="ed" style="display: <%= ((foo.isTrue) ? string.Empty : "none") %>"> <%= ((foo.isTrue) ? foo.Name: "false foo") %>"` ...

How to return JSON from a HandleError filter?

aspnet mvc has the HandleError filter that will return a view if an error occurs, but if an error occurs when calling a JsonResult Action how can I return a JSON object that represents an error? I don't want to wrap the code in each action method that returns a JsonResult in a try/catch to accomplish it, I'd rather do it by adding a 'Ha...

Setting result for IAuthenticationFilter

I am looking to set the result action from a failed IAuthorizationFilter. However I am unsure how to create an ActionResult from inside the Filter. The controller doesn't seem to be accible from inside the filter so my usual View("SomeView") isn't working. Is there a way to get the controler or else another way of creating an actionre...

Redirect to different controller

I have some code in an IAuthorizationFilter which redirects the user to a login page but I'm having trouble changing the controller which is used. So I might do public void OnAuthorization(AuthorizationContext context) { UserController u = new UserController(); context.Result = u.Login(); context.Cancel = true; } But this resu...

ASP.NET MVC Preview 5 - Html.Image helper has moved namespace

We've just updated ASP.NET from Preview 3 to Preview 5 and we've run into a problem with the Html.Image HtmlHelper in our aspx pages. It seems that Html.Image has moved from System.Web.Mvc into Microsoft.Web.Mvc, and the only way we've found to access the helper now is to add an import statement to every .aspx page that uses it. All the...

MVC Preview 5 - Rendering A View To String For Testing

I was reading a post by Brad Wilson (http://bradwilson.typepad.com/blog/2008/08/partial-renderi.html) on the new ViewEngine changes to MVC Preview 5 and thought that it would be great to be able to render a view to string for use in tests. I get the impression from the article that it may be possible to achieve this but cannot figure out...

MVC Preview 5 - ViewData/HTML Helper Quirk

The following code is in the /Courses/Detail action: [AcceptVerbs("GET")] public ActionResult Detail(int id) { ViewData["Title"] = "A View Title"; return View(tmdc.GetCourseById(id)); } The tmdc.GetCourseById(id) method returns an instance of type "Course" for the View. In the View I am using <%= HTML....

Do you believe that ASP.Net MVC is ready for production?

I really like the fact that Microsoft has taken a commitment to bring MVC to the Web. To this end, I have become excited about converting one of my existing ASP.NET apps to MVC and wanted to know if I may be jumping the gun. While this site is using MVC, it's still technically in beta...what are your thoughts? ...

What's the best way to set up data access for an ASP.NET MVC project?

I am starting a new ASP.NET MVC project to learn with, and am wondering what's the optimal way to set up the project(s) to connect to a SQL server for the data. For example lets pretend we have a Product table and a product object I want to use to populate data in my view. I know somewhere in here I should have an interface that gets i...

Action Naming Convention

Has anybody established a good naming convention for action in MVC? I was specifically looking at ASP.net MVC but it is a general question. For instance I have an action which displays the login screen (Login) and one which process the login request from that page (LoginTest). I'm not keen on the names and I have a lot of the applicai...

What is the best way to send a HTML email from Asp.net MVC?

I would like to be able to render a view and send it as an email, similar to what can be done with Ruby on Rails. What is the best way to do this? EDIT: My solution so far is to use a templating engine (NHaml, StringTemplate.net). It works but I would prefer not to have a second template engine in my site. ...

ASP.NET MVC routing

Up until now I've been able to get away with using the default routing that came with ASP.NET MVC. Unfortunately, now that I'm branching out into more complex routes, I'm struggling to wrap my head around how to get this to work. A simple example I'm trying to get is to have the path /User/{UserID}/Items to map to the User controller's...