[英]ASP.NET Page Not Found Error in New Page with Code Behind
我固有了一個大型ASP.NET Web表單應用程序,並嘗試將一個新的帶有代碼的test.aspx頁添加到一個新創建的文件夾-test中。
Test.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>
test.aspx.cs:
using System;
public partial class Test: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("This is a test");
}
}
在我的web.config文件中,我可以使任何人都可以訪問Test文件夾。
<location path="Test">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
當我使用https://localhost/Test/Test.aspx在開發機器中訪問它時。 工作正常。 但是在我部署到服務器之后。 我執行https://myserver/Test/Test.aspx時出現錯誤404-找不到頁面。
該服務器是Windows 2008 R2。 除此新頁面外,其他所有現有頁面均可正常運行。
將另一個沒有代碼的新頁面Test1.aspx放在同一Test文件夾中。
<script language="c#" runat="server">
public void Page_Load(object sender, EventArgs e)
{
Response.Write("hello, world!");
}
</script>
https://myserver/Test/Test1.aspx 。 它返回我“你好,世界!”。
將任何圖像文件放在同一文件夾中也可以訪問。 https://myserver/Test/test.gif 。
對於一個簡單的帶代碼隱藏的新.aspx頁,可能會出錯嗎? 我在Windows事件日志或IIS日志中看不到任何內容。 如何調試這個問題?
請幫忙
從評論移到。
用CodeBehind替換CodeFile可解決此問題。
基本上,如果需要在部署之前在Visual Studio中進行編譯,則可以使用CodeBehind 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.