本文整理汇总了C#中System.Net.HttpListenerContext.Redirect方法的典型用法代码示例。如果您正苦于以下问题:C# HttpListenerContext.Redirect方法的具体用法?C# HttpListenerContext.Redirect怎么用?C# HttpListenerContext.Redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.HttpListenerContext
的用法示例。
在下文中一共展示了HttpListenerContext.Redirect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleRequest
public bool HandleRequest(Client client, HttpListenerContext context, params string[] args)
{
this.context = context;
if (client.Connected())
{
context.Redirect("../home");
return true;
}
if (context.GetMethod() == HttpMethod.GET)
{
this.ShowRegister(client);
}
else if (context.GetMethod() == HttpMethod.POST)
{
Dictionary<string, string> requestData = context.GetData();
if (requestData.ContainsKey("username") && requestData.ContainsKey("password"))
{
string username = requestData["username"];
string password = PasswordManager.Hash(requestData["password"]);
User user = UserManager.CreateUser(username, password);
if (user != null)
{
if (UserManager.Login(username, requestData["password"], client))
{
context.Redirect("../home");
return true;
}
}
else
{
this.ShowRegister(client, new Error("Couldn't create the user!"));
return false;
}
}
this.ShowRegister(client, new Error("Something wrong happened there!"));
}
return true;
}
示例2: HandleRequest
public bool HandleRequest(Client client, HttpListenerContext context, params string[] args)
{
this.context = context;
if (client.Connected())
{
context.Redirect("../home");
return true;
}
if (context.GetMethod() == HttpMethod.GET)
{
this.ShowLogin(client);
}
else if(context.GetMethod() == HttpMethod.POST)
{
Dictionary<string, string> requestData = context.GetData();
if (requestData.ContainsKey("username") && requestData.ContainsKey("password"))
{
string username = requestData["username"];
string password = requestData["password"];
if (UserManager.Login(username, password, client))
{
context.Redirect("../home");
}
else
{
this.ShowLogin(client, new Error("Invalid username or password"));
}
}
else
{
this.ShowLogin(client, new Error("Error"));
}
}
return true;
}
示例3: HandleRequest
public bool HandleRequest(Client client, HttpListenerContext context, params string[] args)
{
if (!UserManager.Connected(client))
{
context.Redirect("../login");
return true;
}
User user = UserManager.GetUser(UserManager.GetUserID(client));
Home_Template template = new Home_Template(user);
context.Send(template.Render());
return true;
}