Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify root (/) location in web.config?

How does one specify root location in web.config to allow unauthenticated users access it?

The root location is served by default.aspx, but users normally don't see default.aspx, they just see http://mysite.com/.

So I've added

  <location path="~/default.aspx">     <system.web>       <authorization>         <allow users="*"/>       </authorization>     </system.web>   </location> 

Which works if user hits mysite.com/default.aspx, but if user hits mysite.com/ - he is still redirected to login page.

I've tried <location path="~"> (does not help) and also <location path="~/">, <location path=""> (site fails completely) and could not make it work.

Any ideas?

like image 216
Michael Entin Avatar asked Feb 20 '12 08:02

Michael Entin


People also ask

Where do I put the location tag in web config?

Use the location element in the Web. To specify settings that apply to a specific application or directory, add the <location> element to the <configuration> element of an application Web. config file.

What is the root tag of web config file?

config is an XML file, it can consist of any valid XML tags, but the root element should always be <configuration> . Nested within this tag you can include various other tags to describe your settings.

Where is my web config file located?

The Web. Config file is used to configure Oracle Web Application functionality. This file is typically installed in the c:\Inetput\wwwroot\WebApp directory.

How do I change the default document in asp net web config?

If Login. aspx form set to default form use to web. config file .


1 Answers

Try this one:

<system.web>     <urlMappings enabled="true">         <add url="~/" mappedUrl="~/default.aspx" />     </urlMappings>     <authorization>         <allow roles="admin"/>         <deny users="*" />     </authorization> </system.web> <location path="Default.aspx">     <system.web>         <authorization>             <allow users="*" />         </authorization>     </system.web> </location> 
like image 83
Alexey Smolyakov Avatar answered Sep 28 '22 19:09

Alexey Smolyakov