我正在使用asp.net 4.0(web窗體),並且我在登錄頁面上遇到錯誤,只要頁面發回來驗證憑據,它就會顯示以下錯誤。Sys.WebForms.PageRequestManagerServerErrorException在回發
Sys.WebForms.PageRequestManagerServerErrorException:未知的錯誤 在處理服務器上的任務發生。從服務器返回的狀態代碼 是:404。
我想告訴你的人完整的場景。因爲我在我的處理程序中使用server.transer,並使用以下URL訪問登錄頁面。
這是我使用母版頁的.aspx內容頁面。
<asp:TextBox ID="txtEmail" runat="server" Width="200px" AutoCompleteType="None"></asp:TextBox>
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Width="200px" AutoCompleteType="None"></asp:TextBox>
<asp:Button ID="cmdLogin" runat="server" Text="Login" OnClick="cmdLogin_Click" />
</ContentTemplate>
</asp:UpdatePanel>
這裏是我的處理程序ProcessRequst
方法
public void ProcessRequest(HttpContext context)
{
string stringRqourl = context.Request.RawUrl;
tbl_contactcompanies tblCustomer = null;
try
{
int lastIndex = stringRqourl.ToLower().LastIndexOf("/");
int lenStart = lastIndex - 1;
int wordLengeth = stringRqourl.Length - lenStart;
string customerCodeName = stringRqourl.Substring(1, stringRqourl.Length - wordLengeth);
tblCustomer = CustomerManager.GetCustomerByWebCode(customerCodeName);
}
catch (Exception)
{
tblCustomer = null;
}
if (tblCustomer == null)
Redirect404Page(context);
else
{
Dictionary<string, string> paramsdic = new Dictionary<string, string>();
paramsdic.Add(ParameterName.CUSTOMER_ID, tblCustomer.ContactCompanyID.ToString());
paramsdic.Add(ParameterName.IS_ALLOW_WEB_ACCESS, tblCustomer.IsAllowWebAccess.ToString());
//Note it is server.transer which creates the following :
// "CorpLogin.aspx?IsAllowWebAcces=1&&CustomerID=123"
HttpContext.Current.Server.Transfer(Utils.BuilQueryString("CorpLogin.aspx", paramsdic));
}
}
下面是我遵循STPES:在URL i型 :
第1步http://localhost/coprprate123/login和客戶處理程序監聽這樣的請求,並解析例如在我的情況下,ID是123和sever.transfer的requst轉移到CorpLogin.aspx和url保持不變(即我想要什麼來實現)
第2步:
提供一些無效的憑據,通過單擊登錄按鈕發送頁面回發,並出現以下js錯誤。
Sys.WebForms.PageRequestManagerServerErrorException:處理服務器上的任務時發生未知錯誤 。從服務器返回的狀態代碼 是:404。
只要刪除更新面板,就不會在回發時發生。我堅持並在互聯網上搜索了很多。請問如果有人可以看看這個問題
問候, 薩爾曼。
你可以檢查步驟2:以客戶爲空?在這種情況下,你正在做Redirect404Page(上下文) – 2012-01-09 07:55:34
親愛的,我已經chcecked了,處理程序沒有任何問題,它成功地將我的請求轉移到corpLogin.aspx頁面。該問題在該頁面開始後,一旦獲得回發。請注意,我正在使用server.transfer而不是Response.Redirect。 – 2012-01-09 09:23:20