简体   繁体   中英

loginURL in web.config forms authentication within virtual directory based page

I have an application in a virtual directory (ASP.Net 4.0 C#). It is secured with forms authentication. Within my application are sub directories so that I have a content tree that matches the rough order of my website

www.server.com/application/sub-directory1/sub-directory2/

 <forms name=".ADAuthCookie" loginUrl="Login.aspx" slidingExpiration="true" timeout="100" defaultUrl="~/Default.aspx"/>

What should the "loginUrl" be to allow it to work from a subdirectory? ie if your session times out, how can you get the loginUrl to redirect you to the right place?

if you set it to loginUrl="~/Login.aspx" and you are in sub-directory 1, it redirects you to www.server.com/application/sub-directory1/login.aspx which does not exist. I want it to always redirect to www.server.com/application/login.aspx

Thanks

我有同样的问题,我通过从appSettings部分中删除了这一问题

Did you configure the loginUrl inside the web.config file located at the root folder? If so that should work. I have an asp.net 3.5 with a similar structure. When I timeout inside http://localhost/Providence /Member/Mail/NewMessage.aspx, I am redirected to http://localhost/Providence/Login.aspx?ReturnUrl=%2fProvidence%2fMember%2fMail%2fNewMessage.aspx .

I have not tried this with asp.net 4.0 though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM