Windows 2003 problems

Last post 01-25-2008 10:49 PM by jamesgeurts. 10 replies.

Sort Posts:

  • Windows 2003 problems

    01-23-2008, 5:30 PM
    • Member
      point Member
    • dagda2
    • Member since 01-07-2008, 2:01 PM
    • Posts 28

     

    Hi all,

    I am trying to put a build of a web app. using ASP.NET MVC on a Windows 2003 test server.  Up to now I have been running with Cassini.

    I simply cannot get it to work.

    I have installed .NET 3.5 and installed the CTP meaning that the .dlls are in the GAC.

    I can hit the default page but when I try and type in any restful URLs that should route to controllers, I get HTTP 404.

    I have no idea what is going on.

    Can anyone help me out or experienced anything similar?

    Cheers

    Paul

     

  • Re: Windows 2003 problems

    01-23-2008, 6:25 PM
    • Member
      point Member
    • dagda2
    • Member since 01-07-2008, 2:01 PM
    • Posts 28

    Ok,

    I just noticed the line:

    // Note: Change Url= to Url="[controller].mvc/[action]/[id]" to enable
    // automatic support on IIS6


    So apologies for that

    I now have the problem that none of my urls are routing.

    I have a log in page with a form defined as such: 

    <
    form id="main" action='<%= Url.Action("LogIn", "LogIn") %>' method="post">

    Which renders my form tag:
    <form id="main" action='/ncontinuity2.web/LogIn.mvc.aspx/LogIn' method="post"> 

    The problem I have is it does not now go into the LogIn method.  It only renders goes to Index.

    Can anyone see what I am doing wrong?

    CHeers

    Paul

  • Re: Windows 2003 problems

    01-23-2008, 7:19 PM
    • Member
      205 point Member
    • ghotiman
    • Member since 08-28-2002, 9:36 AM
    • Missoula, MT
    • Posts 57

    What do your other routing rules look like?

  • Re: Windows 2003 problems

    01-23-2008, 7:21 PM
    • Member
      205 point Member
    • ghotiman
    • Member since 08-28-2002, 9:36 AM
    • Missoula, MT
    • Posts 57

    Just noticed in your code: <form id="main" action='/ncontinuity2.web/LogIn.mvc.aspx/LogIn' method="post"> 

     

    I don't think that the .aspx should be there.  If you rewrite your form like this:

    <form id="main" action='/ncontinuity2.web/LogIn.mvc/LogIn' method="post"> 

    does it work?

  • Re: Windows 2003 problems

    01-24-2008, 9:39 AM
    • Member
      point Member
    • dagda2
    • Member since 01-07-2008, 2:01 PM
    • Posts 28

    Hi,

    OK I got to the bottom of all but one of my problems. 

    First up, I had to change my routes to [controller].mvc.aspx/[action] etc.  I tried adding .mvc to be handled by aspnet_isapii in IIS but could not get it to work.  So I went for .mvc.aspx.  An example of a routing is:

    RouteTable.Routes.Add(new Route{Url = "[controller].mvc.aspx/[action]/[id]",      Defaults = new { action = "Index", id = (string)null },RouteHandler = typeof(MvcRouteHandler)

    });

    Next I had to change my authentication element to the following:

    <authentication mode="Forms">
          <forms name="dncontinuity2user" loginUrl="/LogIn.mvc.aspx" defaultUrl="/BCM.mvc.aspx" protection="All" timeout="30" path="/"/>

    </authentication><authorization>      <allow users="*" />

    </authorization>

    The change I had here was to allow all users.  I then added location elements for each controller like this.

    <location path="BCM.mvc.aspx">      <system.web>            <authorization>                  <deny users="?" />            </authorization>      </system.web>

    </location>

    I don’t like having to add a new location element for each controller.  Previously I denied all users and then just allowed the various controllers that could grant public access.

    I am left with one problem.  The root URL ‘/’ will not default to the HomeController.  I have the following addition to the RouteTable:

    I have tried many things.  In desperation I thinking of redirecting in the BeginRequest event in Global.asax.

    Any ideas why Default route is not working.

     

  • Re: Windows 2003 problems

    01-24-2008, 12:09 PM
    • Member
      205 point Member
    • ghotiman
    • Member since 08-28-2002, 9:36 AM
    • Missoula, MT
    • Posts 57

    You should have this route at the bottom of the list:

          RouteTable.Routes.Add(new Route
          {
            Url = "Default.aspx",
            Defaults = new { controller = "Home", action = "Index", id = (string)null },
            RouteHandler = typeof(MvcRouteHandler)
          });

  • Re: Windows 2003 problems

    01-25-2008, 6:42 AM
    • Member
      28 point Member
    • byron.walker
    • Member since 01-11-2008, 1:55 AM
    • Posts 14

    Trust me when I say you dont need any of the above to get your mvc app working on Windows 2003.

     

    Have a look at my post here for hints about setting up forms auth in ASP.NET. And here for how to get rid of the 'Default.aspx' route. 

  • Re: Windows 2003 problems

    01-25-2008, 6:54 AM
    • Member
      point Member
    • dagda2
    • Member since 01-07-2008, 2:01 PM
    • Posts 28

    Well that being the case how do you handle extensionless Urls?

    The only way in IIS6 is to use wild card application mapping which is not a scalable answer.

  • Re: Windows 2003 problems

    01-25-2008, 9:14 AM
    • Member
      point Member
    • dagda2
    • Member since 01-07-2008, 2:01 PM
    • Posts 28

    I don't think this will work in IIS6 either:

     

    RouteTable.Routes.Add(new Route
          {
            Url = "",
            Defaults = new
            {
              controller = "Home",
              action = "Index",
              id = (string)null
            },
            RouteHandler = typeof(MvcRouteHandler)
          }
        );
      You need to specifiy Default.aspx.


  • Re: Windows 2003 problems

    01-25-2008, 9:21 AM
    • Contributor
      7,054 point Contributor
    • rjcox
    • Member since 12-19-2007, 2:14 PM
    • Basingstoke, UK
    • Posts 1,444

    dagda2:
      You need to specifiy Default.aspx
     

    In your route, and IIS6 will default to mapping a folder only URL to the first of a list of default files which includes Default.aspx.
     

    Richard
  • Re: Windows 2003 problems

    01-25-2008, 10:49 PM
    • Member
      93 point Member
    • jamesgeurts
    • Member since 12-11-2003, 1:23 PM
    • Milwaukee, WI
    • Posts 28

    fyi, I setup a step by step "tutorial" for how to setup asp.net mvc on iis6 with pretty urls.  It uses the .mvc extension mapping and isapi_rewrite, so it performs well and has nice urls.

    Thanks

    James Geurts
    Personal Weblog: http://www.biasecurities.com/blogs/jim/
    Work: Property Center
    Filed under: , ,
Page 1 of 1 (11 items)