.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

areas mvc2 iis 6.0

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

hi all,

i have another problem. I am trying to deploy my MVC2 website on iis 6.0. I have added the following to my global.asax:


routes.MapRoute("Default","{controller}.mvc/{action}/{id}", new {controller = "Home", action = "Index", id = UrlParameter.Optional } );

I added the ".mvc" extention because i read that iis 6 needs this. And it works. BUT!! I also use areas, and this is something iis 6 does not understand.

I have the following:
No Areapath: Home.mvc/Index (works fine, no area used)
Areapath: Projects/Overview/Index (does not work!!)

I don't now how to solve this, i hope somebody can help me.




View Complete Post

More Related Resource Links

MVC2 issue - Stuck. Trying to create a cms with nested partials


I am currently trying to display multiple items on a single page. I am not sure as to how to tackle this. What I have is a database table that has all the page data in. I have this run as a PagesController and this works fine. However what I would like to do is, if say the Products page is selected via the menu, I want to pull back not only the Products page html but also get all the products, and even be able to pull them through via category. I was trying to use a partial view, but I can't get it to work. The same would be for other pages, having partial views to display the other content, ie if Gallery is selected, the page html for Gallery shows and it then can push to a partial view that pulls all the gallery images from the gallery db table and so on. 

Maybe I am tackling this the wrong way. I have the pages stored in the db to allow for a CMS system I have setup. Maybe I need to use models for all the other items(Products, Gallery, Videos and such) and use the partial for the page html?

Any help would be greatly appreciated as I am confused.

Tip #107 Did you know . How to improve debugging performance for MVC2 application in Visual Studio 2

VS2010 Ultimate included IntelliTrace functionality by default.  IntelliTrace captures events (e.g. exceptions), and can affect performance of debugging. The typical performance hit is about 5% in the default mode (collection can be increased to...(read more)

How to switch between HTTP and HTTPS in ASP.NET MVC2


ASP.NET MVC2 has the new RequireHttpsAttribute that you can use to decorate any action to force any non-secure request to come through HTTPS (SSL).  It can be used as simply as this:

        public ActionResult LogOn()

Now any request to the LogOn action that is not over HTTPS will automatically be redirected back to itself over HTTPS.  This is very useful and easy to implement.

Unfortunately though, once the scheme is changed to HTTPS, all following requests will also be under HTTPS, which is not necessarily what you want.  In most cases you do not need all requests to your site to be secure but only certain ones such as the logon page or pages that accept credit card information. 

To handle this you can override the Controller.OnAuthorization method.  From within this method, you can check to see if the RequireHttps attribute is set on the Controller Action by searching the Attributes collection of the ActionDescriptor object. If the RequireHttpsAttribute is not set AND the request is under SSL, then return a redirect result to the HTTP (no

ASP.NET MVC3 Areas and Razor views produce errors?


The view at '~/Areas/SomeArea/Views/List/Index.cshtml' must derive from ViewPage, ViewPage, ViewUserControl, or ViewUserControl.

The project structure is pretty much default. There is one area called SomeArea. It has a single controller called List. It does nothing except:

public ActionResult Index()
    return View("~/Areas/SomeArea/Views/List/Index.cshtml");

The view looks like:

@inherits System.Web.Mvc.WebViewPage<dynamic>
    View.Title = "Index";
    LayoutPage = "~/Views/Shared/_Layout.cshtml";


I have tried emptying the entire file part by part and nothing seems to help. If I create a controller and view outside the area it works just fine. If I create an aspx view it works fine as well. Is it possible the default razor view engine doesn't support areas at this time?

The areas are registered too.

public static void RegisterRoutes(RouteCollection routes)
        "Default", // Route name
        "{controller}/{action}/{id}", // URL with parameters

ModelBinders obsolete in MVC2?



I have a shopping cart that uses MVC 1 (guide from the book "Pro ASP.NET MVC Framework" by Steve Sanderson). Now that MVC 2 and VS2010 are released, the shopping cart no longer works.

Is there any changes about the ModelBinders.Binders.Add(), is it obsolete in MVC2? The code binder below wasn't hit at all in Application_Start(). Sad


    Sub Application_Start()

ModelBinders.Binders.Add(GetType(ShoppingCart.Model.Cart), New CartModelBinder)
End Sub


Imports System.Web.Mvc

Public Class CartModelBinder
Implements System.Web.Mvc.IModelBinder

Private Const cartSessionKey As String = "_cart"

Public Function BindModel(ByVal controllerContext As ControllerContext, ByVal bindingContext As ModelBindingContext) As Object Implements IModelBinder.BindModel
If (Not (bindingContext.Model) Is Nothing) Then
Throw New InvalidOperationException("Cannot update instances")
End If
Dim cart As ShoppingCart.Model.Cart = CType(controller

Multiple forms on the same page MVC2: how to handle (including validation from model)



It should be simple; although I'm having a hard time to figure out the best way to do it. I've MVC2 pages with multiple forms on the same page having different functionalities.

What's the best way to handle this; including the MVC2 way of validation from the model?


MVC2 Music Store - How to get store controller - store.aspx working {genre names displayed}



<p>Select from <%: Model.NumberOfGenres %> genres:</p><ul> <% foreach (string genreName in Model.Genres) { %>

<li> <%: genreName %> </li>

<% } %>


MOST PEOPLE WILL BE USING VISUAL STUDIO 2008 sp1, to get this to work change the <%:, ONLY WITH SEMI COLONS, TO <%=

Asp.net MVC2 Linq to Sql



I am a little new to this concept so bear with me.

1) I need to query atleast 35 tables using linq to sql(SQL server database) . I am not able to add all the database entities in Linq to sql classes?

2)(View Model issue) When I use List<Reportcollection> and also List<Receipt> to convert the result then its giving an error that "Cannot convert list<anonymous> to list<string>"


Please suggest me both the issues. Thanks in Advance


ASP.NET MVC2 -- Linq to sql -- Crystal Reports



I need to generate almost 73 reports using Crystal reports using SQL SERVER. I might get more data from XML so opted ASP.NET MVC2.

I have 2 questions:

1) I have a lot of tables to generate Data Context around 35 ( I was thinking to write more stored procedures). Any help with that?

2) Is it possible to create one Report viewer/Crystal report  to display these reports ( I just need to  Read data by querying on input No CRUD operations)

If somebody can explain me the best process to use. Thanks in Advance. 

Why does MVC2 reset my Context.User but MVC1 doesn't?

The question comes from a previous thread, but I would like to ask a more specific question from anyone in the know.Why does MVC2 reset my Context.User, discarding changes made in Application_AuthenticateRequest but MVC1 does not?Repro is pretty simple:Start an MVC1 and MVC2 new project. In both of them add the following code in global.asax: protected void Application_AuthenticateRequest(Object sender, EventArgs e) { if (Context.Request.IsAuthenticated) { FormsIdentity ident = (FormsIdentity)Context.User.Identity; Context.User = new System.Security.Principal.GenericPrincipal(ident, new[] { "FooAdmin" }); bool result = User.IsInRole("FooAdmin"); } } // break hereNow in both HomeController.cs files change the Index Action to: public ActionResult Index() { bool result = User.IsInRole("FooAdmin"); ViewData["Message"] = ""; // break here return View(); }Deploy to IIS, attach debugger on the "// break here" lines and then login to each site in turn.You should find that under MVC1 the result variable at both breakpoints is true, but in MVC2 it is false in the Index action.Anybody have any idea why? Is this a bug or by design? Any way around it?

error in MVC2 on empty string form fields which are required: "This property cannot be set to a null

In model I have:[DisplayName("ISBN")] [Required(ErrorMessage = "ISBN is required.")] [StringLength(50, ErrorMessage = "ISBN book must have max {1} chars.")] [DisplayFormat(ConvertEmptyStringToNull = false)] public string isbn { get; set; }But when I submit form with empty field ISBN I have an error - ConstraintException: This property cannot be set to a null value.I have find that other people have the same problem and they say that debbugger in VS2010 works wrong - yes ?http://p2p.wrox.com/book-professional-asp-net-mvc-2/79788-constraintexception-unhandled-user-code.html#post259245http://efreedom.com/Question/1-3129080/Server-Side-Validation-REQUIRED-String-Property-MVC2-Entity-Framework-Workhttp://mvcmusicstore.codeplex.com/workitem/6604

css and mvc2

Hi,Is it just me or is mvc 2 just not that friendly when it comes to working with css? Say i want to make one particular page with a different color background from the rest. Well, i can't just embed within that page the css rule as there is no <head> in the aspx page. The only option is to make a new .master page just for that page, and a new css page attachment to that master page. So i've had to create 2 files just so i have the freedom of working on a particular aspx page with css.Is this right or is there simpler way to add css to aspx pages?

Visual Studio 2010, MVC2.0, IIS7, .NET4 deployment problem

I have a problem where I can get an MVC2.0 application using .NET3.5 running in IIS, but when I upgrade it to .NET4.0, the browser just reports error 500 Internal Server Error. The problem is easy to replicate as follows.  Firstly, to show it works with .NET3.5: Create a new MVC2.0 application in Visual Studio 2010, using the inbuilt starter template. Run the application using the development server, and the Home & About pages display fine. Publish the application to a directory. Copy the directory to a subdirectory under inetpub/wwwroot on my Vista computer, running IIS7 Create a new application in IIS Manager & select the DefaultAppPool (integrated pipeline) Browse the application and Home & About pages are displayed. Then the problem I have is after upgrading to .NET4.0: Change to .NET4.0 for the project in Visual Studio Build & this runs fine with the development server. Publish the application & set up IIS as before, except choosing the application pool ASP.NET v4.0 (integrated pipeline) Browse the application, and I get the 500 Internal Server Error I'm guessing there is some extra configuration required - can anyone help? I've deliberately used the default MVC installation to eliminate any variables caused by my programming .. Thanks in advance, Steve

Migrating MVC1 application to MVC2

I am having a Asp.net MVC1 based application which needs to be migrated to Asp.net MVC2. I opened this application in vs2010 and it automatically migrated it to MVC2. However one of its code line is creating problem during page exceution. I have following line in Application_start funtion of Global.asax ModelBinders.Binders.DefaultBinder = new Microsoft.Web.Mvc.DataAnnotations.DataAnnotationsModelBinder(); This is because Microsoft.Web.MVC.DataAnnotations dll is missing in MVC2. I tried to skip this error by commenting this code but that is also giving error. Can somebody please guide me about its replacement code. Thanks in advance Cheers TicArch

Iterate through all areas

I am wondering if MVC offers a handy function to iterate through all areas.  I know I can search the sub-directories of Areas to achieve this.  I am just curious.

How to make a default Area in MVC2??

I have the area Blog with controllers (Post and Blog)i want that when the user acess my site without one area, it should redirect him to the Blog area inthe blog controller and in the index actionif i use:            routes.MapRoute(                "ClearPath",                "",                new {area = "Blog",controller = "Blog", action = "Index" }            );i got one error cause he search the view in the root folder: The view 'Index' or its master was not found. The following locations were searched:~/Views/Blog/Index.aspx~/Views/Blog/Index.ascx~/Views/Shared/Index.aspx~/Views/Shared/Index.ascx

MVC2 NerdDinner - Data no longer saves after adding ViewModel

I am writing this post to document some issues I ran into, and hopefully help anybody else who gets stuck in the same place.  I am creating the NerdDinner application via the Professional ASP.NET MVC 2 book,  and once I got to the ViewModel part (pages 88-91), I noticed none of my data was saving any longer.  I discovered several errors and areas of confusion in these pages of the book, which I will list now. Page 88:  When it says to add the DinnerFormViewModel class, it doesn't say what folder to add it to.  On page 89, the Inherits example (NerdDinner.Controllers.DinnerFormViewModel) implies it was added to the Controllers folder, but if that were so, the code on page 88 would need to use Models.Dinner instead of just Dinner.  No big deal; just put it in Models and change the Inherit statement on page 89 to use NerdDinner.Models.DinnerFormViewModel. Page 89:  At the bottom of the page is some wrong code.  Since the properties of Dinner are now one level deeper, all references to m.Title, m.Country, etc, need to be m.Dinner.Title, m.Dinner.Country, etc.  The statements above the code are also incorrect ("Notice... we are not changing the names of the input elements... the form elements will still be named...") -- the form elements will actually change from "Title", "Country&quo
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend