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


C# IResponse.Write方法代码示例

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


在下文中一共展示了IResponse.Write方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public override void Execute(IRequest req, IResponse res, object requestDto)
        {
            var authErrorMessage = "";
            try
            {
                // Perform security check
                if (CanExecute(req))
                    return;
            }
            catch (System.Exception ex)
            {
                authErrorMessage = ex.Message;
                var message = string.Format("Blocked unauthorized request: {0} {1} by ip = {2} due to {3}",
                    req.Verb,
                    req.AbsoluteUri,
                    req.UserHostAddress ?? "unknown",
                    authErrorMessage);
                Log.Error(message);
            }

            // Security failed!
            var responseMessage = "You are not authorized. " + authErrorMessage;

            res.StatusCode = (int)HttpStatusCode.Unauthorized;
            res.StatusDescription = responseMessage;
            res.AddHeader(HttpHeaders.WwwAuthenticate, string.Format("{0} realm=\"{1}\"", "", "custom api"));
            res.ContentType = "text/plain";
            res.Write(responseMessage);
            res.Close();
        }
开发者ID:CodeRevver,项目名称:notekeeper-api,代码行数:30,代码来源:AuthSignatureRequired.cs

示例2: Execute

        public void Execute(IRequest httpReq, IResponse httpRes)
        {
            HostContext.AppHost.AssertFeatures(Feature.Metadata);

            httpRes.ContentType = "text/xml";

            var baseUri = httpReq.GetParentBaseUrl();
            var optimizeForFlash = httpReq.QueryString["flash"] != null;
            var operations = new XsdMetadata(HostContext.Metadata, flash: optimizeForFlash);

            try
            {
                var wsdlTemplate = GetWsdlTemplate(operations, baseUri, optimizeForFlash, httpReq.ResolveBaseUrl(), HostContext.Config.SoapServiceName);
                httpRes.Write(wsdlTemplate.ToString());
            }
            catch (Exception ex)
            {
                log.Error("Autogeneration of WSDL failed.", ex);

                httpRes.Write("Autogenerated WSDLs are not supported "
                    + (Env.IsMono ? "on Mono" : "with this configuration"));
            }
        }
开发者ID:BBSDeadEye,项目名称:ServiceStack,代码行数:23,代码来源:WsdlMetadataHandlerBase.cs

示例3: ProcessRequest

        public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
        {
            if (HostContext.ApplyCustomHandlerRequestFilters(httpReq, httpRes))
                return;
            if (textContents == null && bytes == null)
                return;

            httpRes.ContentType = contentType;

            if (textContents != null)
                httpRes.Write(textContents);
            else if (bytes != null)
                httpRes.OutputStream.Write(bytes, 0, bytes.Length);

            httpRes.Flush();
            httpRes.EndHttpHandlerRequest(skipHeaders: true);
        }
开发者ID:CLupica,项目名称:ServiceStack,代码行数:17,代码来源:StaticContentHandler.cs

示例4: ProcessRequest

        /// <summary>
        /// Only manage full page results
        /// </summary>
        /// <param name="httpReq"></param>
        /// <param name="httpRes"></param>
        /// <param name="operationName"></param>
        public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
        {
            var path = httpReq.PathInfo;

            string output;
            switch (Path.GetFileNameWithoutExtension(path))
            {
                case "profiler-results":
                    output = Results(httpReq, httpRes);
                    break;

                default:
                    output = NotFound(httpRes);
                    break;
            }

            httpRes.Write(output);
        }
开发者ID:Dams33,项目名称:Servicestack-SelfHost-Profiler,代码行数:24,代码来源:SelfhostProfilerHandler.cs

示例5: ProcessRequest

		public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
		{
			var path = httpReq.PathInfo;

			string output;
			switch (Path.GetFileNameWithoutExtension(path))
			{
				//case "mini-profiler-jquery.1.6.2":
				//case "mini-profiler-jquery.tmpl.beta1":
				case "ssr-jquip.all":
				case "ssr-includes":
					output = Includes(httpReq, httpRes, path);
					break;

				case "ssr-results":
					output = Results(httpReq, httpRes);
					break;

				default:
					output = NotFound(httpRes);
					break;
			}

			httpRes.Write(output);
		}
开发者ID:0815sugo,项目名称:ServiceStack,代码行数:25,代码来源:MiniProfilerHandler.cs

示例6: ProcessRequest

        public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
		{
			var response = this.RequestInfo ?? GetRequestInfo(httpReq);
			response.HandlerFactoryArgs = HttpHandlerFactory.DebugLastHandlerArgs;
			response.DebugString = "";
			if (HttpContext.Current != null)
			{
				response.DebugString += HttpContext.Current.Request.GetType().FullName
					+ "|" + HttpContext.Current.Response.GetType().FullName;
			}
            if (HostContext.IsAspNetHost)
            {
                var aspReq = (HttpRequestBase) httpReq.OriginalRequest;
                response.GetLeftPath = aspReq.Url.GetLeftPart(UriPartial.Authority);
                response.Path = aspReq.Path;
                response.UserHostAddress = aspReq.UserHostAddress;
                response.ApplicationPath = aspReq.ApplicationPath;
                response.ApplicationVirtualPath = HostingEnvironment.ApplicationVirtualPath;
                response.VirtualAbsolutePathRoot = VirtualPathUtility.ToAbsolute("/");
                response.VirtualAppRelativePathRoot = VirtualPathUtility.ToAppRelative("/");                
            }

            var json = JsonSerializer.SerializeToString(response);
            httpRes.ContentType = MimeTypes.Json;
			httpRes.Write(json);
		}
开发者ID:nustack,项目名称:ServiceStack,代码行数:26,代码来源:RequestInfoHandler.cs

示例7: ProcessRequest

        public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
        {
            var response = this.RequestInfo ?? GetRequestInfo(httpReq);
            response.HandlerFactoryArgs = HttpHandlerFactory.DebugLastHandlerArgs;
            response.DebugString = "";
            if (HttpContext.Current != null)
            {
                response.DebugString += HttpContext.Current.Request.GetType().FullName
                    + "|" + HttpContext.Current.Response.GetType().FullName;
            }
            if (HostContext.IsAspNetHost)
            {
                var aspReq = (HttpRequestBase)httpReq.OriginalRequest;
                response.GetLeftPath = aspReq.Url.GetLeftPart(UriPartial.Authority);
                response.Path = aspReq.Path;
                response.UserHostAddress = aspReq.UserHostAddress;
                response.ApplicationPath = aspReq.ApplicationPath;
                response.ApplicationVirtualPath = HostingEnvironment.ApplicationVirtualPath;
                response.VirtualAbsolutePathRoot = VirtualPathUtility.ToAbsolute("/");
                response.VirtualAppRelativePathRoot = VirtualPathUtility.ToAppRelative("/");

                if (!Env.IsMono)
                {
                    var userIdentity = aspReq.LogonUserIdentity;
                    if (userIdentity != null)
                    {
                        response.LogonUserInfo = new Dictionary<string, string> {
                            { "Name", userIdentity.Name },
                            { "AuthenticationType", userIdentity.AuthenticationType },
                            { "IsAuthenticated", userIdentity.IsAuthenticated.ToString() },
                            { "IsAnonymous", userIdentity.IsAnonymous.ToString() },
                            { "IsGuest", userIdentity.IsGuest.ToString() },
                            { "IsSystem", userIdentity.IsSystem.ToString() },
                            { "Groups", userIdentity.Groups.Map(x => x.Value).Join(", ") },
                        };
                        var winUser = userIdentity.User;
                        if (winUser != null)
                        {
                            response.LogonUserInfo["User"] = winUser.Value;
                            response.LogonUserInfo["User.AccountDomainSid"] = winUser.AccountDomainSid != null
                                ? winUser.AccountDomainSid.ToString()
                                : "null";
                            response.LogonUserInfo["User.IsAccountSid"] = winUser.IsAccountSid().ToString();
                        }
                    }
                }
            }

            var json = JsonSerializer.SerializeToString(response);
            httpRes.ContentType = MimeTypes.Json;
            httpRes.Write(json);
            httpRes.EndHttpHandlerRequest(skipHeaders:true);
        }
开发者ID:tchrikch,项目名称:ServiceStack,代码行数:53,代码来源:RequestInfoHandler.cs

示例8: WriteHeader

 public void WriteHeader(IResponse response)
 {
     // TODO: Eventually I'd like to make this write as it goes instead of
     // buffering into a stream, but I need to create the ResponseStream
     // type first.
     response.Write (ToHeaderString ());
 }
开发者ID:imintsystems,项目名称:Waser,代码行数:7,代码来源:Cookie.cs

示例9: ProcessRequest

		public override void ProcessRequest(IRequest httpReq, IResponse httpRes, string operationName)
		{
			var response = this.RequestInfo ?? GetRequestInfo(httpReq);
			response.HandlerFactoryArgs = HttpHandlerFactory.DebugLastHandlerArgs;
			response.DebugString = "";
			if (HttpContext.Current != null)
			{
				response.DebugString += HttpContext.Current.Request.GetType().FullName
					+ "|" + HttpContext.Current.Response.GetType().FullName;
			}

            var json = JsonSerializer.SerializeToString(response);
            httpRes.ContentType = MimeTypes.Json;
			httpRes.Write(json);
		}
开发者ID:0815sugo,项目名称:ServiceStack,代码行数:15,代码来源:RequestInfoHandler.cs


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