views:

487

answers:

2

I have published my MVC project to an an IIS 6 server. Running under the application MVCapp. The web project gets the url: www.domain.com/MVCapp/.

I use forms login for authentication and got an issue after publishing.

The web.config is as follows:

<authentication mode="Forms">
<forms name="CTWebCookie" loginUrl="~/Account/Login" defaultUrl="~/Home/Index" slidingExpiration="true" protection="All" timeout="20"/>
</authentication>

For example if I run the following code in an action:

FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();

..everything works great and the user is redirected to www.domain.com/MVCapp/Account/Login.

However, when the authentication has timed out - at the next page request the user will be redirected to www.domain.com/Account/Login. The application root is not routed and the url points at the IIS root.

How can I make the application resolve the correct url after authorization timeout and why does it work when programamticly signing out not not when it automaticly signs out?

Please advice.

A: 

ASP.NET MVC project template uses ~/Account/Login. Check your web.config:

<authentication mode="Forms">
    <forms loginUrl="~/Account/Login" ... />
</authentication>

UPDATED:

Is there any app on the IIS root (www.domain.com/)? If so - try removing this app from IIS. You could also add this line in your Site.Master:

 <%= System.Web.Security.FormsAuthentication.LoginUrl %>

to see if your loginUrl is exactly /MVCapp/Account/Login or anything else

Hope this helps

eu-ge-ne
My config settings didnt get posted. Sorry about that. I have edited my post now and as you can see I use the same url as the template.
A: 

Nevermind, figured it out (stupid mistake), thanks for the help though.

The problem was a javascript on the login page that reloaded the page as target.top in case of asyncronous requests. The url in the javascript hadn't been resolved correctly.