简体   繁体   中英

Change URL asp.net

I'm building a project in Visual Studio using C#. When I try to run the program I get Error Http 404. My question is how can I change my URL

http://localhost:55188/login.aspx?ReturnUrl=%2f 

to

http://localhost:55188/Index.aspx.

The page login.aspx does no longer exist.

This is my web.config

<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Forms">

  <forms defaultUrl="addRole.aspx" path="/"/>
</authentication>
<authorization>
  <deny users="?"/>
</authorization>
</system.web>  
<location path="LoggedIn.aspx">
<system.web>
  <authorization>
    <allow users="*"/>
  </authorization>
</system.web>
</location>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
</configuration>

Thank you.

The page you try to reach requires authintication and your web.config says login.aspx can provide that. Change your web.config and you'll be fine.

Here is your web.config without authentication requirements:

<configuration> <system.web> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" /> </system.web>
<appSettings> <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" /> </appSettings> </configuration>

As Matthias Aslund correctly started, you have specified that you want your users to be authenticated but have not specified which Login page you wish users to be redirected to in order to login by using the "LoginUrl" attribute on the forms element in the Web.config file. The default value of "Login.aspx" is therefore being used, as specified on this MSDN page on the LoginUrl attribute . The "DefaultUrl" attribute has a different purpose and is used as the default page to redirect users to after logging on if one is not specified using the "ReturnUrl" querystring value that is visible in your URL above - see the MSDN page on the DefaultUrl attribute for more.

If you no longer have any authentication in your application, that is to say any user can access your application without a username and password, then you need to change your Web.config as follows. It is extremely important that you are clear that any user who is able to reach your application will now be able to access any part of it, and that there will be no restrictions based on the fact that the user is authenticated/known to the application, is a specific user, or is in a specific role.

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="None" />
  </system.web>  
  <appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
  </appSettings>
</configuration>

This replaces the whole of the contents of your Web.config file you have provided above, but you must be clear that this removes all authentication from your application (which appears to be what you want).

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