3 Attachment(s)
All DirectEvents Is Error?
I met a strange question.
All of the Development environment is correct, after publishing to IIS and found that all the errors of all the Ajax way and All DirectEvents and return is: Status Code: 200
But also through the firebug difference lies in that: the right to return is a Json request string, and returns the error turned out to be the whole page source code.
Someone can help me,Thanks!
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Web._Default" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" CleanResourceUrl="false" />
<ext:Window ID="Window1" runat="server" Width="300" Title="Login" Icon="ApplicationHome"
AutoHeight="true" Closable="false" Padding="5" Layout="Form" LabelWidth="65"
LabelAlign="Right">
<Items>
<ext:TextField ID="txtLoginName" runat="server" FieldLabel="UserName" Width="170" TabIndex="1">
</ext:TextField>
<ext:TextField ID="txtPassword" runat="server" FieldLabel="Password" InputType="Password"
Width="170" TabIndex="2">
</ext:TextField>
</Items>
<Buttons>
<ext:Button ID="btnLogin" runat="server" Text="Login">
<DirectEvents>
<Click OnEvent="btnLogin_Click"></Click>
</DirectEvents>
</ext:Button>
</Buttons>
</ext:Window>
</form>
</body>
</html>
Code:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
}
}
protected void btnLogin_Click(object sender, EventArgs e)
{
string strUrl = string.Empty;
try
{
TbUserEntity entity = new UserService().Login(txtLoginName.Text.Trim());
if (entity != null && entity.PassWord.Equals(StringHelper.PasswordMD5(txtPassword.Text.Trim())))
{
FormsAuthenticationTicket Ticket = null;
Ticket = new FormsAuthenticationTicket(1, entity.LoginName, DateTime.Now, DateTime.Now.AddHours(2), false, JSON.Serialize(entity), FormsAuthentication.FormsCookiePath);
string HashTicket = FormsAuthentication.Encrypt(Ticket);
HttpCookie UserCookie = new HttpCookie(FormsAuthentication.FormsCookieName, HashTicket);
UserCookie.HttpOnly = true;
UserCookie.Path = FormsAuthentication.FormsCookiePath;
UserCookie.Expires = Ticket.Expiration;
Response.Cookies.Add(UserCookie);
if (Request["ReturnUrl"] != null)
{
strUrl = Context.Request["ReturnUrl"];
}
else
{
strUrl = "Main.aspx";
}
}
else
{
X.Msg.Alert("Error", "Faile!").Show();
}
}
catch (Exception ex)
{
LogHelper.ErrorLog.Error("Error", ex);
}
if (strUrl != string.Empty)
{
Response.Redirect(strUrl);
}
}
}