简体   繁体   English

更改URL asp.net

[英]Change URL asp.net

I'm building a project in Visual Studio using C#. 我正在使用C#在Visual Studio中构建一个项目。 When I try to run the program I get Error Http 404. My question is how can I change my URL 当我尝试运行该程序时,出现错误Http404。我的问题是如何更改我的URL。

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

to

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

The page login.aspx does no longer exist. 页面login.aspx不再存在。

This is my web.config 这是我的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. 您尝试访问的页面需要验证,并且您的web.config表示login.aspx可以提供该验证。 Change your web.config and you'll be fine. 更改您的web.config,就可以了。

Here is your web.config without authentication requirements: 这是没有身份验证要求的web.config:

<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. 在Matthias Aslund正确启动后,您已指定要对用户进行身份验证,但未指定希望用户重定向到的“登录”页面,以便使用Web上form元素上的“ LoginUrl”属性进行登录。配置文件。 The default value of "Login.aspx" is therefore being used, as specified on this MSDN page on the LoginUrl attribute . 因此,如在此MSDN页面上LoginUrl属性上所指定的,将使用默认值“ Login.aspx”。 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. “ DefaultUrl”属性的用途不同如果未使用上面URL中可见的“ ReturnUrl”查询字符串值指定用户登录,则该属性将用作默认页面,以在登录后将用户重定向到该页面 -请参见DefaultUrl上的MSDN页面属性

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. 如果您的应用程序中不再具有任何身份验证,也就是说, 任何用户都可以在没有用户名和密码的情况下访问您的应用程序,那么您需要按以下方式更改Web.config。 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). 这将替换上面提供的Web.config文件的全部内容,但是必须清楚,这将从应用程序中删除所有身份验证(这似乎是您想要的)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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