草庐IT

max-request-size

全部标签

c# - 使用 WebClient 和 C#,即使响应为 (400) Bad Request,我如何获取返回的数据?

我正在使用GoogleTranslateAPI并trycatch当我收到error时返回的数据.(仅供引用:我知道APIkey是错误的,我只是在测试它)。问题是浏览器,您可以通过单击链接看到,显示错误信息,但C#抛出WebException,我似乎无法获得响应数据。这是我的代码:stringurl="https://www.googleapis.com/language/translate/v2?key=INSERT-YOUR-KEY&source=en&target=de&q=Hello%20world";WebClientclnt=newWebClient();//Getstrin

c# - System.Web.Http.ApiController.get_Request() 中缺少方法

我有一个Controller。publicsealedclassAccountsController:BaseApiController{privatereadonlyIDatabaseAdapter_databaseAdapter;publicAccountsController(IDatabaseAdapterdatabaseAdapter){_databaseAdapter=databaseAdapter;}[AllowAnonymous][Route("create")]publicasyncTaskCreateUser(CreateUserBindingModelcreate

c# - "Collection was of a fixed size"带有 POCO 的 EF4 异常

我将EF4与WCF和POCO结合使用。我删除了POCO实体中的所有虚拟关键字。我有Employee和Team实体,两者之间的关系是1:N,意味着一名员工只能分配到一个团队。我想在现有团队中添加新员工。以下代码在客户端。privatevoidbtnAdd_Click(objectsender,RoutedEventArgse){TeamteamFromDb=ServiceProxy.GetService.GetTeamById(181);EmployeenewEmp=newEmployee{UserName="username"};newEmp.Team=teamFromDb;Servi

c# - 隐式类型数组 : why we can't set array size explicitly?

C#语言规范(7.6.10.4)说,数组创建表达式有树种:newnon-array-type[expression-list]rank-specifiersoptarray-initializeroptnewarray-typearray-initializernewrank-specifierarray-initializer第三个用于隐式类型数组:varfoo=new[]{1,2,3};问题:在隐式类型数组的情况下,是否有任何重要的理由禁止显式设置数组大小?与这种语法相比,它看起来像是不对称行为:varfoo=newint[3]{1,2,3};更新。稍微澄清一下。我可以看到,显式设

c# - fiddler /C# : search content of request/response for special phrases

这是我第一次访问stackoverflow,现在我对这个网站感到非常满意。它已经帮助我获得了FiddlerCore嵌入到MSVisualC#2008ExpressEdition中。只需要在MSVisualC#EE中从项目资源管理器(Projektmappenexplorer)创建对fiddlercoredll的引用(Verweis)。希望这是它在英文版中的名称。在此之后,您可以使用Fiddler.FiddlerApplication等。我的任务是什么?我想创建一个小程序,它能够使用FiddlerCore检查特殊JavaScript代码的请求/响应主体。这使开发人员能够检查他们的代码在其

c# - Request.Url.Query 和 Request.QueryString 有什么区别?

我一直在追踪一个关于UrlRewriting应用程序的错误。该错误表现为查询字符串中某些变音符号的编码问题。基本上,问题是基本上是/search.aspx?search=heřmánek的请求被重写为“search=he%c5%99m%c3%a1nek”的查询字符串正确的值(使用一些不同的工作代码)是将查询字符串重写为“search=he%u0159m%u00e1nek”注意两个字符串之间的区别。但是,如果您将两者都发布,您将看到Url编码重现相同的字符串。直到您使用context.Rewrite函数,编码才会中断。损坏的字符串返回“heÅmánek”(使用Request.QueryS

c# - 调用 HttpContext.Request 时如何避免 HttpException?

所以HttpContext.Request如果在全局启动内调用则抛出publicHttpRequestget_Request(){if(this.HideRequestResponse){thrownewHttpException(SR.GetString("Request_not_available"));}returnthis._request;}这实际上是有记录的ASP.NETwillthrowanexceptionifyoutrytousethispropertywhentheHttpRequestobjectisnotavailable.Forexample,thiswoul

c# - 值不能为空。参数名称 : request

我正在使用nunit创建单元测试,所有这些代码在运行时都运行良好。我在下面有这个protectedHttpResponseMessage代码,当它返回时我的Controller正在调用它。但是,报错:"Valuecannotbenull.Parametername:request"isdisplaying.当我检查请求时,它实际上是null。问题:我将如何编写单元测试代码以返回HttpResponseMessage?错误显示在这一行:protectedHttpResponseMessageCreated(Tresult)=>Request.CreateResponse(HttpStat

c# - 检查 Request.IsAjaxRequest 在我的 asp.net mvc4 中总是返回 false

我的Controller中有以下代码publicActionResultIndex(stringsearchTerm=null){System.Threading.Thread.Sleep(5000);varaccountdefinition=repository.FindAccountDefinition(searchTerm).ToList();if(Request.IsAjaxRequest()){returnPartialView("_CustomerTable",accountdefinition);}returnView(accountdefinition);}但如果我使用

c# - 将 EF6 Code First 字符串流畅地设置为 nvarchar(max)

我正在使用FluentAPI构建EF6代码优先模型。我的理解是,默认情况下,字符串将是nvarchar(max),(坦率地说)对于默认值来说是愚蠢的。所以我添加了以下约定代码以将最大默认长度设置为255个字符:modelBuilder.Properties().Configure(p=>p.HasMaxLength(255));然后我像这样创建了一个装饰器:[AttributeUsage(AttributeTargets.Property,AllowMultiple=false,Inherited=true)]publicclassTextAttribute:Attribute{}我想