views:

525

answers:

1

I am building an ASP.NET MVC application using the 1.0 release using Visual Web Developer Express (temporarily). I am using the SqlMembership Provider and forms authentication to handle security for the site. My site security requires the user to login before seeing anything -- there are no anonymous user pages except for the login page itself.

I have changed changed the routes in my global.asax.cs as follows:

    routes.MapRoute(
        "Default",                                              // Route name
        "{controller}/{action}/{id}",                           // URL with parameters
        new { controller = "Patients", action = "Search", id = "" }  // Parameter defaults
    );

I published the app on my local IIS (Windows XP) and hit the virtual directory like so: http://mymachinename/App/ . I am directed to the login (Account/Login) page as expected. However, after successfully logging in using a new user account, I am redirected to Home/Index rather than Patients/Search. The Home controller and Index view both still exist in the app, since I have not removed them yet (we may decide to display a home page as the first page of the app).

I am about to remove the Home controller and associated views from the project, since I have tried a number of other things, including a clean publish from scratch, restarting the web server and clearing my browser cache. But I am curious as to why this might happen since I cannot find any other reference to Home/Index in any of my project files, including global.asax.cs and web.config. Anybody have any ideas?

Thanks.

A: 

Is there any chance the Home/Index is defined as the defaultUrl in web.config?

<authentication mode="Forms">
    <forms loginUrl="~/Account/LogOn" timeout="2880" 
        defaultUrl="~/Home/Index" />
</authentication>
çağdaş
Thanks, cagdas, you put me onto the right path. While the defaultUrl was not specified, the Logoff action on the Account controller that was generated when the project was created contained a RedirectToAction("Index", "Home"). I must have been trying to login as the new user after logging in as the admin and using the app to create the user though my admin interface, then logging out. Thus the login screen was set to redirect to /Home/Index. I didn't think to check the controller. Thanks!
Rich
Ah yes, I should have also suggested checking the controller. I'm glad you figured it out.
çağdaş