cs0815
cs0815

Reputation: 17418

ReturnUrl issue with asp.net mvc

I have to deal with a legacy asp.net mvc app, which is not configured as I am used to. After a normal logout via:

FormsAuthentication.SignOut();

and

return RedirectToAction("Index", "Home");

the URI contains:

ReturnUrl=%2f

This is not usually the case. How can I suppress this?

Alternatively, when I try to access a page that requires authentication/authorization the login page appears but no appropriate ReturnUrl= is generated (i.e. the URI stays as it is).

Is this an IIS issue, which I have read somewhere, or is the asp.net FormsAuthenticationModule not properly configured? Thanks.

Upvotes: 6

Views: 2354

Answers (3)

Santosh K
Santosh K

Reputation: 65

If nothing works then add authentication mode="Windows" in your system.web attribute in your Web.Config file. hope it will work for you.

Upvotes: 0

Erik Funkenbusch
Erik Funkenbusch

Reputation: 93464

ReturnUrl is added during an unauthorized redirect. Someone appears to be redirecting the root url (/) to itself or to Home/Index. %2f is the encoded form of "/".

I would check the authorization section of the web.config for something that looks wrong.

Upvotes: 2

Yin
Yin

Reputation: 301

This is depends on you routing, right? If you have this as you last route configuration:

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

Upvotes: 0

Related Questions