簡體   English   中英

更改URL asp.net

[英]Change URL asp.net

我正在使用C#在Visual Studio中構建一個項目。 當我嘗試運行該程序時,出現錯誤Http404。我的問題是如何更改我的URL。

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

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

頁面login.aspx不再存在。

這是我的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>

謝謝。

您嘗試訪問的頁面需要驗證,並且您的web.config表示login.aspx可以提供該驗證。 更改您的web.config,就可以了。

這是沒有身份驗證要求的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>

在Matthias Aslund正確啟動后,您已指定要對用戶進行身份驗證,但未指定希望用戶重定向到的“登錄”頁面,以便使用Web上form元素上的“ LoginUrl”屬性進行登錄。配置文件。 因此,如在此MSDN頁面上LoginUrl屬性上所指定的,將使用默認值“ Login.aspx”。 “ DefaultUrl”屬性的用途不同如果未使用上面URL中可見的“ ReturnUrl”查詢字符串值指定用戶登錄,則該屬性將用作默認頁面,以在登錄后將用戶重定向到該頁面 -請參見DefaultUrl上的MSDN頁面屬性

如果您的應用程序中不再具有任何身份驗證,也就是說, 任何用戶都可以在沒有用戶名和密碼的情況下訪問您的應用程序,那么您需要按以下方式更改Web.config。 非常重要的一點是,您必須清楚,能夠訪問您的應用程序的任何用戶現在都可以訪問應用程序的任何部分,並且基於對用戶進行身份驗證/對應用程序已知的事實,將沒有任何限制。 ,是特定用戶,還是特定角色。

<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>

這將替換上面提供的Web.config文件的全部內容,但是必須清楚,這將從應用程序中刪除所有身份驗證(這似乎是您想要的)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM