• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Web.HttpRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Web.HttpRequest的典型用法代码示例。如果您正苦于以下问题:C# HttpRequest类的具体用法?C# HttpRequest怎么用?C# HttpRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HttpRequest类属于System.Web命名空间,在下文中一共展示了HttpRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CaptureRouterData

 private void CaptureRouterData(HttpRequest request)
 {
     var mode = (request.QueryString["rptmode"] + "").Trim();
     ReportDataObj.IsLocal = mode == "local" ? true : false;
     ReportDataObj.ReportName = request.QueryString["reportname"] + "";
     string dquerystr = request.QueryString["parameters"] + "";
     if (!String.IsNullOrEmpty(dquerystr.Trim()))
     {
         var param1 = dquerystr.Split(',');
         foreach (string pm in param1)
         {
             var rp = new Parameter();
             var kd = pm.Split('=');
             if (kd[0].Substring(0, 2) == "rp")
             {
                 rp.ParameterName = kd[0].Replace("rp", "");
                 if (kd.Length > 1) rp.Value = kd[1];
                 ReportDataObj.ReportParameters.Add(rp);
             }
             else if (kd[0].Substring(0, 2) == "dp")
             {
                 rp.ParameterName = kd[0].Replace("dp", "");
                 if (kd.Length > 1) rp.Value = kd[1];
                 ReportDataObj.DataParameters.Add(rp);
             }
         }
     }
 }      
开发者ID:williampicanco,项目名称:Projeto-ASP.NET-MVC5_controle-Receitas-Despesas,代码行数:28,代码来源:ReportBasePage.cs


示例2: GetRouteData

        /// <summary>
        /// Parses specified url and returns a RouteData instance. 
        /// Then, for example, you can do: routeData.Values["controller"]
        /// </summary>
        public static RouteData GetRouteData(this RouteCollection routeCollection, string url, string queryString = null)
		{
            var request = new HttpRequest(null, url, queryString);
            var response = new HttpResponse(new StringWriter());
            var httpContext = new HttpContext(request, response);
            return RouteTable.Routes.GetRouteData(new HttpContextWrapper(httpContext));
		}
开发者ID:matutee,项目名称:Bardock.Utils,代码行数:11,代码来源:RouteCollectionExtensions.cs


示例3: update

        public JObject update(HttpRequest blogForm)
        {
            bool result = false;
            string msg = "";
            if (blogForm != null)
            {
                string id_str = blogForm["ID"];
                string Username = blogForm["Username"];

                try
                {
                    int id = UtilNumber.Parse(id_str);
                    Blog blog = db.Blog.Single(e => e.ID.Equals(id));
                    base.CopyProperties(blog, blogForm);
                    blog.UpdateTime = DateTime.Now;
                    db.SaveChanges();
                    msg = "保存成功!";
                    result = true;
                }
                catch (Exception error)
                {
                    msg = "操作失败:" + error.Message + ",请重试!";
                }
            }
            return new JObject(
                new JProperty("success", result),
                new JProperty("msg", msg)
            );
        }
开发者ID:skygreen2001,项目名称:Betterlife.Net,代码行数:29,代码来源:ExtServiceBlog.ashx.cs


示例4: BuildCanvas

        public static FacebookSignature BuildCanvas(HttpRequest request)
        {
            string[] keys = request.QueryString.Keys
                .OfType<string>()
                .Where(s => s.StartsWith(fbCanvasPrefix))
                .ToArray();
            if (keys.Length > 0)
            {
                var result = new FacebookSignature(keys.ToDictionary(k => k.Substring(fbCanvasPrefix.Length), k => request.QueryString[k])) { Signature = request.QueryString[fbCanvasSignature] };
                result.Secret = Configuration.ConfigurationSection.GetSection().FindByApiKey(request.QueryString[fbCanvasApiKey]).AppSecret;
                return result;
            }

            keys = request.Form.Keys
                .OfType<string>()
                .Where(s => s.StartsWith(fbCanvasPrefix))
                .ToArray();
            if (keys.Length > 0)
            {
                var result = new FacebookSignature(keys.ToDictionary(k => k.Substring(fbCanvasPrefix.Length), k => request.Form[k])) { Signature = request.Form[fbCanvasSignature] };
                result.Secret = Configuration.ConfigurationSection.GetSection().FindByApiKey(request.Form[fbCanvasApiKey]).AppSecret;
                return result;
            }

            return null;
        }
开发者ID:mdekrey,项目名称:FacebookSharp,代码行数:26,代码来源:WebSignatureHelper.cs


示例5: CreateFromHttpRequest

        /// <summary>
        /// Converts a standard <see cref="HttpRequest"/> to a <see cref="RequestModel"/>
        /// Copies over: URL, HTTP method, HTTP headers, query string params, POST params, user IP, route params
        /// </summary>
        /// <param name="request"></param>
        /// <param name="session"></param>
        /// <param name="scrubParams"></param>
        /// <returns></returns>
        public static RequestModel CreateFromHttpRequest(HttpRequest request, HttpSessionState session, string[] scrubParams = null)
        {
            var m = new RequestModel();

            m.Url = request.Url.ToString();
            m.Method = request.HttpMethod;
            m.Headers = request.Headers.ToDictionary();
            m.Session = session.ToDictionary();

            m.QueryStringParameters = request.QueryString.ToDictionary();
            m.PostParameters = request.Form.ToDictionary();

            // add posted files to the post collection
            if (request.Files.Count > 0)
                foreach (var file in request.Files.Describe())
                    m.PostParameters.Add(file.Key, "FILE: " + file.Value);

            // if the X-Forwarded-For header exists, use that as the user's IP.
            // that will be the true remote IP of a user behind a proxy server or load balancer
            m.UserIp = IpFromXForwardedFor(request) ?? request.UserHostAddress;

            m.Parameters = request.RequestContext.RouteData.Values.ToDictionary(v => v.Key, v => v.Describe());

            if (scrubParams != null)
            {
                m.Headers = Scrub(m.Headers, scrubParams);
                m.Session = Scrub(m.Session, scrubParams);
                m.QueryStringParameters = Scrub(m.QueryStringParameters, scrubParams);
                m.PostParameters = Scrub(m.PostParameters, scrubParams);
            }

            return m;
        }
开发者ID:TheNeatCompany,项目名称:RollbarSharp,代码行数:41,代码来源:RequestModelBuilder.cs


示例6: ProcessRequest

 public string ProcessRequest(HttpRequest request)
 {
     StreamReader reader = new StreamReader(request.InputStream);
     string messageContent = reader.ReadToEnd();//This is the request XML from the USSD Gateway
     //UssdRequestMessage message = GenerateObject(messageContent);//Map the attributes on to the object
     return messageContent;
 }
开发者ID:behailus,项目名称:geez_ussd,代码行数:7,代码来源:UssdHttpHandler.cs


示例7: ProgressWorkerRequest

 public ProgressWorkerRequest(HttpWorkerRequest wr, HttpRequest request)
 {
     this._originalWorkerRequest = wr;
     this._request = request;
     this._boundary = this.GetBoundary(this._request);
     this._requestStateStore = new Areas.Lib.UploadProgress.Upload.RequestStateStore(this._request.ContentEncoding);
 }
开发者ID:asifashraf,项目名称:Radmade-Portable-Framework,代码行数:7,代码来源:ProgressWorkerRequest.cs


示例8: FakeHttpContext

 /// <summary>
 /// Mock an <see cref="HttpContext"/> object with the base URL, together with appropriate
 /// host headers so that code that doesn't operate under an <see cref="HttpContext"/>
 /// can still use one in replacement.
 /// </summary>
 public static HttpContext FakeHttpContext(this HttpContext realContext)
 {
     var baseUrl = realContext.GetPublicFacingBaseUrl();
     var request = new HttpRequest(string.Empty, baseUrl.ToString(), string.Empty);
     var response = new HttpResponse(null);
     return new HttpContext(request, response);
 }
开发者ID:sithy,项目名称:Raid-Points-System-.NET,代码行数:12,代码来源:UrlExtensions.cs


示例9: FakeHttpContext

        public static HttpContext FakeHttpContext()
        {
            using (var stringWriter = new StringWriter())
            {
                var httpRequest = new HttpRequest("", "http://abc", "");

                var httpResponse = new HttpResponse(stringWriter);
                var httpContext = new HttpContext(httpRequest, httpResponse);

                var sessionContainer = new HttpSessionStateContainer(
                    "id",
                    new SessionStateItemCollection(), 
                    new HttpStaticObjectsCollection(),
                    10,
                    true,
                    HttpCookieMode.AutoDetect,
                    SessionStateMode.InProc,
                    false);

                httpContext.Items["AspSession"] = typeof(HttpSessionState).GetConstructor(
                    BindingFlags.NonPublic | BindingFlags.Instance,
                    null,
                    CallingConventions.Standard,
                    new[] {typeof(HttpSessionStateContainer)},
                    null)
                    .Invoke(new object[] {sessionContainer});

                return httpContext;
            }
        }
开发者ID:TomJerrum,项目名称:FinalYearProjectBlog,代码行数:30,代码来源:HttpContextFaker.cs


示例10: Save

        public void Save(string ipAddress, HttpContext context, HttpRequest request, HttpResponse response)
        {
            ELSLog esLog = new ELSLog();
            esLog.ElsIpaddress = ipAddress;
            /*  var x = request.Path;

              x = Getapifunction(x);

              switch (request.HttpMethod)
              {
                  case "GET" :
                      x = "SEE " + x;
                      break;
                  case "POST":
                      x = "SENT " + x;
                      break;
              }*/
            // if (x == "/api/contact")
            // {
            //     x = "sendqueue";}
            esLog.ElsRequest = "[" + DateTime.Now.ToString("dd/MMM/yyyy:HH:mm:ss zz") + "]" + " \"" + request.HttpMethod + " "
                + request.Path + "\" " + response.StatusCode + " " + request.TotalBytes + " \"" + request.UrlReferrer + "\" " + "\"" + request.UserAgent + "\"" + " " + request.Form;

            /*    if (HttpContext.Current.Session != null)
                {
                   // context.Session[Userlog] = esLog;
                    Session[Userlog] = esLog;
                }*/
            context.Items[Userlog] = esLog;
        }
开发者ID:tzkwizard,项目名称:ELS,代码行数:30,代码来源:TestLogHandler.cs


示例11: save

 public JObject save(HttpRequest commentForm)
 {
     bool result = false;
     string msg = "";
     if (commentForm != null)
     {
         Comment comment = new Comment();
         base.CopyProperties(comment, commentForm);
         try
         {
             comment.Comment1 = comment.Content;
             comment.CommitTime = DateTime.Now;
             comment.UpdateTime = DateTime.Now;
             db.Comment.Add(comment);
             db.SaveChanges();
             msg = "保存成功!";
             result = true;
         }
         catch (Exception error)
         {
             msg = "操作失败:" + error.Message + ",请重试!";
         }
     }
     return new JObject(
         new JProperty("success", result),
         new JProperty("msg", msg)
     );
 }
开发者ID:skygreen2001,项目名称:Betterlife.Net,代码行数:28,代码来源:ExtServiceComment.ashx.cs


示例12: GetBrowserName

        /// <summary>
        /// 获得浏览器名称(包括版本号)
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static string GetBrowserName(HttpRequest request)
        {
            HttpBrowserCapabilities browser = request.Browser;

            if (browser == null)
                return "Unknown";

            string text;
            if (browser.Browser == "IE")
            {
                if (browser.Beta)
                    text = string.Concat("Internet Explorer ", browser.Version, "(beta)");
                else
                    text = "Internet Explorer " + browser.Version;
            }
            else
            {
                string userAgent = request.UserAgent;

                if (userAgent != null && userAgent.IndexOf("Chrome") != -1)
                    text = "Chrome";
                else if (userAgent != null && userAgent.IndexOf("Safari") != -1)
                    text = "Safari";
                else if (browser.Beta)
                    text = string.Concat(browser.Browser, " ", browser.Version, "(beta)");
                else
                    text = string.Concat(browser.Browser, " ", browser.Version);
            }

            return text;
        }
开发者ID:fly1986,项目名称:PublicCls,代码行数:36,代码来源:ClsRequest.cs


示例13: CustomErrorsEnabled

        internal bool CustomErrorsEnabled(HttpRequest request)
        {
            try
            {
                if (DeploymentSection.RetailInternal)
                {
                    return true;
                }
            }
            catch
            {
            }
            switch (this.Mode)
            {
                case CustomErrorsMode.RemoteOnly:
                    return !request.IsLocal;

                case CustomErrorsMode.On:
                    return true;

                case CustomErrorsMode.Off:
                    return false;
            }
            return false;
        }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:CustomErrorsSection.cs


示例14: ReadStream

        private void ReadStream(Stream stream, HttpRequest request, string username, AsyncFileUploadProgress progress, AsyncFileUploadRequestParser parser)
        {
            const int bufferSize = 1024 * 4; // in bytes

            byte[] buffer = new byte[bufferSize];
            while (progress.BytesRemaining > 0)
            {
                int bytesRead = stream.Read(buffer, 0, Math.Min(progress.BytesRemaining, bufferSize));
                progress.TotalBytesRead = bytesRead == 0
                                          ? progress.ContentLength
                                          : (progress.TotalBytesRead + bytesRead);

                if (bytesRead > 0)
                {
                    parser.ParseNext(buffer, bytesRead);
                    progress.FileName = parser.CurrentFileName;
                }

                _cacheService.SetProgress(username, progress);

#if DEBUG
                if (request.IsLocal)
                {
                    // If the request is from local machine, the upload will be too fast to see the progress.
                    // Slow it down a bit.
                    System.Threading.Thread.Sleep(30);
                }
#endif
            }
        }
开发者ID:ashuthinks,项目名称:webnuget,代码行数:30,代码来源:AsyncFileUploadModule.cs


示例15: ChunkExists

 public bool ChunkExists(HttpRequest request)
 {
     var identifier = request.QueryString["flowIdentifier"];
     var chunkNumber = int.Parse(request.QueryString["flowChunkNumber"]);
     var chunkFullPathName = GetChunkFilename(chunkNumber, identifier);
     return File.Exists(Path.Combine(filesPath.GetFlowJsTempDirectory(), chunkFullPathName));
 }
开发者ID:gkudel,项目名称:Testility,代码行数:7,代码来源:FlowJsService.cs


示例16: DeleteCookie

 public static void DeleteCookie(HttpRequest Request, HttpResponse Response, string name, string value)
 {
     HttpCookie cookie = new HttpCookie(name);
     cookie.Expires = DateTime.Now.AddDays(-1D);
     cookie.Value = value;
     Response.AppendCookie(cookie);
 }
开发者ID:the404,项目名称:xyz,代码行数:7,代码来源:CookieHelper.cs


示例17: IsStaticResource

        /// <summary>
        /// Returns true if the requested resource is one of the typical resources that needn't be processed by the cms engine.
        /// </summary>
        /// <param name="request">HTTP Request</param>
        /// <returns>True if the request targets a static resource file.</returns>
        /// <remarks>
        /// These are the file extensions considered to be static resources:
        /// .css
        ///	.gif
        /// .png 
        /// .jpg
        /// .jpeg
        /// .js
        /// .axd
        /// .ashx
        /// </remarks>
        public static bool IsStaticResource(HttpRequest request)
        {
            if (request == null)
                throw new ArgumentNullException("request");

            string path = request.Path;
            string extension = VirtualPathUtility.GetExtension(path);

            if (extension == null) return false;

            switch (extension.ToLower())
            {
                case ".axd":
                case ".ashx":
                case ".bmp":
                case ".css":
                case ".gif":
                case ".htm":
                case ".html":
                case ".ico":
                case ".jpeg":
                case ".jpg":
                case ".js":
                case ".png":
                case ".rar":
                case ".zip":
                    return true;
            }

            return false;
        }
开发者ID:sdf333,项目名称:MVCDEMO,代码行数:47,代码来源:WebHelper.cs


示例18: Log404

        /// <summary>
        /// Logs the 404 error to a table for later checking 
        /// </summary>
        /// <param name="request"></param>
        /// <param name="settings"></param>
        /// <param name="result"></param>
        public static void Log404(HttpRequest request, FriendlyUrlSettings settings, UrlAction result)
        {
            var controller = new LogController();
            var log = new LogInfo
                {
                    LogTypeKey = EventLogController.EventLogType.PAGE_NOT_FOUND_404.ToString(),
                    LogPortalID = (result.PortalAlias != null) ? result.PortalId : -1
                };
            log.LogProperties.Add(new LogDetailInfo("TabId", (result.TabId > 0) ? result.TabId.ToString() : String.Empty));
            log.LogProperties.Add(new LogDetailInfo("PortalAlias",  (result.PortalAlias != null) ? result.PortalAlias.HTTPAlias : String.Empty));
            log.LogProperties.Add(new LogDetailInfo("OriginalUrl",  result.RawUrl));

            if (request != null)
            {
                if (request.UrlReferrer != null)
                {
                    log.LogProperties.Add(new LogDetailInfo("Referer", request.UrlReferrer.AbsoluteUri));
                }
                log.LogProperties.Add(new LogDetailInfo("Url", request.Url.AbsoluteUri));
                log.LogProperties.Add(new LogDetailInfo("UserAgent", request.UserAgent));
                log.LogProperties.Add(new LogDetailInfo("HostAddress", request.UserHostAddress));
                log.LogProperties.Add(new LogDetailInfo("HostName", request.UserHostName));
            }

            controller.AddLog(log);
        }
开发者ID:uXchange,项目名称:Dnn.Platform,代码行数:32,代码来源:UrlRewriterUtils.cs


示例19: RaygunRequestMessage

        public RaygunRequestMessage(HttpRequest	request, List<string> ignoredFormNames)
        {
            HostName = request.Url.Host;
              Url = request.Url.AbsolutePath;
              HttpMethod = request.RequestType;
              IPAddress = request.UserHostAddress;
              Data = ToDictionary(request.ServerVariables, Enumerable.Empty<string>());
              QueryString = ToDictionary(request.QueryString, Enumerable.Empty<string>());
              Headers = ToDictionary(request.Headers, ignoredFormNames ?? Enumerable.Empty<string>());
              Form = ToDictionary(request.Form, ignoredFormNames ?? Enumerable.Empty<string>(), true);

              try
              {
            var contentType = request.Headers["Content-Type"];
            if (contentType != "text/html" && contentType != "application/x-www-form-urlencoded" && request.RequestType != "GET")
            {
              int length = 4096;
              string temp = new StreamReader(request.InputStream).ReadToEnd();
              if (length > temp.Length)
              {
            length = temp.Length;
              }

              RawData = temp.Substring(0, length);
            }
              }
              catch (HttpException)
              {
              }
        }
开发者ID:klumsy,项目名称:raygun4netWithPowerShell,代码行数:30,代码来源:RaygunRequestMessage.cs


示例20: CanGZipOrDeflate

 private bool CanGZipOrDeflate(HttpRequest request, string encodingHeaderValue)
 {
     string acceptEncoding = request.Headers["Accept-Encoding"];
     if (!string.IsNullOrEmpty(acceptEncoding) && (acceptEncoding.Contains(encodingHeaderValue)))
         return true;
     return false;
 }
开发者ID:jalva,项目名称:JsAndCssCombiner,代码行数:7,代码来源:CombinedResourceHandler.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Web.HttpRequestBase类代码示例发布时间:2022-05-26
下一篇:
C# Web.HttpPostedFileBase类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap