本文整理汇总了C#中Request.Parameter方法的典型用法代码示例。如果您正苦于以下问题:C# Request.Parameter方法的具体用法?C# Request.Parameter怎么用?C# Request.Parameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request.Parameter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Index
public void Index(Request req, Response res)
{
if (!LoginServer.Instance.Conf.Login.IsTrustedSource(req.ClientIp))
return;
var name = req.Parameter("name");
var pass = req.Parameter("pass");
// Check parameters
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(pass))
{
res.Send("0");
return;
}
// Get account
var account = LoginServer.Instance.Database.GetAccount(name);
if (account == null)
{
res.Send("0");
return;
}
// Check password
var passwordCorrect = Password.Check(pass, account.Password);
// Response
res.Send(passwordCorrect ? "1" : "0");
}
示例2: Index
public void Index(Request req, Response res)
{
var name = req.Parameter("name");
var pass1 = req.Parameter("password1");
var pass2 = req.Parameter("password2");
var error = "";
var success = "";
if (name != null && pass1 != null && pass2 != null)
{
if (pass1 != pass2)
{
error = "The passwords don't match.";
goto L_Send;
}
if (name.Length < 4)
{
name = "";
error = "Username too short (min. 4 characters).";
goto L_Send;
}
if (pass1.Length < 6)
{
error = "Password too short (min. 6 characters).";
goto L_Send;
}
if (!Regex.IsMatch(name, @"^[0-9A-Za-z]+$"))
{
error = "Username contains invalid characters.";
goto L_Send;
}
if (WebServer.Instance.Database.AccountExists(name))
{
error = "Account already exists.";
goto L_Send;
}
var passHash = Password.RawToMD5SHA256(pass1);
WebServer.Instance.Database.CreateAccount(name, passHash);
Log.Info("New account created: {0}", name);
name = "";
success = "Account created successfully.";
}
L_Send:
res.Render("web/register.htm", new { error, success, name });
}
示例3: Index
/// <remarks>
/// Parameters:
///
/// Files:
/// ui ^[0-9]{16}\.xml$ XML file containing the ui settings
///
/// Post:
/// char_id long Id of the character
/// name_server string Name of the server
/// ui_load_success bool Whether loading was successful
///
/// Security:
/// Since the client doesn't give us anything but char id and
/// server name, the settings could easily be overwritten
/// by anybody.
/// </remarks>
public void Index(Request req, Response res)
{
// Get file
var file = req.Files.FirstOrDefault(a => a.Name == "ui");
if (file == null || !file.HasData)
{
Log.Error("UiStorageController: Missing file.");
return;
}
// Check file name
if (!Regex.IsMatch(file.FileName, @"^[0-9]{16}\.xml$"))
{
Log.Error("UiStorageController: Invalid file name '{0}'.", file.FileName);
return;
}
var charId = req.Parameter("char_id", null);
var serverName = req.Parameter("name_server", null);
var loadSuccess = req.Parameter("ui_load_success", null);
// Check parameters
if (!Regex.IsMatch(charId, @"^[0-9]{16}$") || !Regex.IsMatch(charId, @"^[0-9A-Za-z_ ]+$"))
{
Log.Error("UiStorageController: Invalid character id ({0}) or server name ({1}).", charId, serverName);
return;
}
var group = charId.Substring(charId.Length - 3);
// Move file
try
{
file.MoveTo("user/save/ui/" + serverName + "/" + group + "/" + file.FileName);
}
catch (Exception ex)
{
Log.Exception(ex, "UiStorageController: Failed to move file.");
}
Log.Info("Character '{0}' uploaded their UI settings.", charId);
// Success
res.Send("1");
}
示例4: Index
public void Index(Request req, Response res)
{
if (!LoginServer.Instance.Conf.Login.IsTrustedSource(req.ClientIp))
return;
var msg = req.Parameter("msg", null);
if (!string.IsNullOrWhiteSpace(msg))
Send.Internal_Broadcast(msg);
}
示例5: Index
public void Index(Request req, Response res)
{
var charId = req.Parameter("char_id");
var serverName = req.Parameter("name_server");
var userFile = req.Files.FirstOrDefault(file => file.Name == "userfile");
var userText = req.Files.FirstOrDefault(file => file.Name == "usertext");
if (charId == null || !Regex.IsMatch(charId, @"^[0-9]+$") || serverName == null || !Regex.IsMatch(serverName, @"^[0-9A-Za-z_]+$") || userFile == null || userText == null)
return;
var key = charId.Substring(charId.Length - 3);
var folder = "user/save/avatar/" + serverName + "/" + key + "/" + charId + "/";
if (userFile.HasData) userFile.MoveTo(folder + "snapshot.jpg");
if (userText.HasData) userText.MoveTo(folder + "snapshot.txt");
Log.Info("Character '{0}' uploaded a snapshot of himself.", charId);
res.Send("1");
}
示例6: Index
public void Index(Request req, Response res)
{
var server = req.Parameter("server", "");
var characterId = req.Parameter("characterid", "");
var characterName = req.Parameter("charname", "");
var file = req.Files.FirstOrDefault();
// Check char name
if (!Regex.IsMatch(characterName, @"^[0-9A-Za-z_]+$"))
return;
// Check file
if (file.FileName != "visualchat.png" || file.ContentType != "image/png")
return;
// Move file
var fileName = string.Format("chat_{0:yyyyMMdd_HHmmss}_{1}.png", DateTime.Now, characterName);
file.MoveTo("user/save/visual-chat/" + fileName);
// Response, URL to image
res.Send("http://" + req.HttpHost + ":" + req.HttpPort + "/" + "user/save/visual-chat/" + fileName);
}