当前位置: 首页>>代码示例>>C#>>正文


C# Response.Send方法代码示例

本文整理汇总了C#中Response.Send方法的典型用法代码示例。如果您正苦于以下问题:C# Response.Send方法的具体用法?C# Response.Send怎么用?C# Response.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Response的用法示例。


在下文中一共展示了Response.Send方法的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");
		}
开发者ID:tkiapril,项目名称:aura,代码行数:29,代码来源:CheckUserController.cs

示例2: Index

		public void Index(Request req, Response res)
		{
			var status = this.CreateStatusText();

			res.ContentType = MediaTypeNames.Text.Plain;
			res.Send(status);
		}
开发者ID:tkiapril,项目名称:aura,代码行数:7,代码来源:StatusController.cs

示例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");
		}
开发者ID:xKamuna,项目名称:aura,代码行数:61,代码来源:UiStorageController.cs

示例4: 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");
		}
开发者ID:tkiapril,项目名称:aura,代码行数:20,代码来源:AvatarUploadController.cs

示例5: 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);
		}
开发者ID:tkiapril,项目名称:aura,代码行数:22,代码来源:VisualChatController.cs

示例6: Index

		public void Index(Request req, Response res)
		{
			res.Send("Aura Web Server");
		}
开发者ID:tkiapril,项目名称:aura,代码行数:4,代码来源:MainController.cs


注:本文中的Response.Send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。