草庐IT

current_section

全部标签

c# - 异步操作后的 HttpContext.Current.Items

考虑以下ASP.NETWebAPI委托(delegate)处理程序:publicclassMyHandler:DelegatingHandler{protectedasyncoverrideTaskSendAsync(HttpRequestMessagerequest,System.Threading.CancellationTokencancellationToken){varguid=Guid.NewGuid();HttpContext.Current.Items["foo"]=guid;//AnAsyncoperationvarresult=awaitbase.SendAsync

c# - Application.Current.Shutdown() 没有杀死我的应用程序

我刚刚启动了一个新的C#/WPF应用程序,并且正在使用WPFContribproject中的NotifyIcon.我可以启动该程序,将“退出”菜单项添加到NotifyIcon的上下文菜单,然后将该项目链接到仅运行Application.Current.Shutdown()的方法。这会关闭主窗口和NotifyIcon,但某些东西会继续运行-从VS运行,它不会离开Debug模式。什么还在运行?或者我该如何检查?编辑我刚刚尝试添加一个调用Application.Current.Shutdown()的按钮,该按钮会正常退出。只有从NotifyIcon调用时我才会遇到问题。为什么会这样?为了澄清

c# - 测试项目test不会执行: unrecognized configuration section entityFramework

当我尝试运行我的测试时,我在我的测试项目的app.config中收到以下错误:ResultMessage:TestmethodMYTESTPROJ.Repositories.MYREPO.MY_TESTthrewexception:System.TypeInitializationException:Thetypeinitializerfor'System.Data.Entity.Internal.AppConfig'threwanexception.--->System.Configuration.ConfigurationErrorsException:Configurations

c# - 具有 HttpContext.Current.User.Identity.IsAuthenticated 的 Webmethods 在 Azure 上不活动后停止工作

我正在使用使用Ajax(json)/Webmethod函数的页面测试Azure服务器。其中一些函数在运行代码之前会检查HttpContext.Current.User.Identity.IsAuthenticated。不幸的是,如果用户已登录并且页面没有向服务器发出完整的回发请求,则只有那些检查HttpContext.Current.User.Identity.IsAuthenticated的webmethods函数会在一对夫妇之后完全停止运行分钟没有给出任何错误。他们甚至不运行else代码块(见下文)。我已经在本地服务器上测试了这些页面,一切正常,即使在长时间不活动之后也是如此。这是

c# - HttpContext.Current.User.Identity.Name 如何知道存在哪些用户名?

这不一定是个问题,我只是好奇它是如何工作的。我有一个方法:publicstaticboolUserIsAuthenticated(){boolisAuthed=false;try{if(HttpContext.Current.User.Identity.Name!=null){if(HttpContext.Current.User.Identity.Name.Length!=0){FormsIdentityid=(FormsIdentity)HttpContext.Current.User.Identity;FormsAuthenticationTicketticket=id.Tick

c# - httpcontext.current.server.mappath 对象引用未设置为对象的实例

我在类中使用以下代码:stringfilePath=HttpContext.Current.Server.MapPath("~/email/teste.html");文件teste.html在文件夹中但是当它打开文件时会生成以下错误:Objectreferencenotsettoaninstanceofanobject. 最佳答案 不要使用Server.MapPath。它很慢。请改用HttpRuntime.AppDomainAppPath。只要您的网站在运行,此属性就始终可供您使用。然后像这样使用它:stringfilePath=P

c# - System.IO.Exception 错误 : "The requested operation cannot be performed on a file with a user-mapped section open."

我在写入XML文件时收到一个非常奇怪的IOException:System.IO.IOException:Therequestedoperationcannotbeperformedonafilewithauser-mappedsectionopen.atSystem.IO.__Error.WinIOError(Int32errorCode,StringmaybeFullPath)atSystem.IO.FileStream.Init(Stringpath,FileModemode,FileAccessaccess,Int32rights,BooleanuseRights,FileSh

c# - MVC @RenderSection "sections have been defined but have not been rendered"脚本。多级页面时

我正在使用MVCv4。我有一个“_BootstrapLayout”页面,它定义了所有twitterbootstrap等内容,一个定义网站布局、导航栏等的主页,以及从主页继承的网站页面。_BootstrapLayout.cshtml_MainPage.cshtml@{Layout="~/Views/Shared/_BootstrapLayout.cshtml";}Index.cshtml@{Layout="~/Views/Shared/_MainPage.cshtml";}所以母版页-->主页-->站点页面_BootstrapLayout页面包含脚本的呈现部分@RenderSection

c# - HttpContext.Current.Session 在 Ashx 文件中为空

我看到了一些问题(Here和Here),但它们没有回答我的问题。我正在尝试使用“ajax.ashx”文件调用Ajax,并在函数中访问Session。由于某种原因,Session对象本身的值为null。使用示例:Session=HttpContext.Current.Session//Thisisnull或者:publicvirtualvoidProcessRequest(HttpContextcontext){System.Web.SessionState.HttpSessionStateSession=context.Session;//Thisisnull}在Web.config中

c# - 服务器违反了协议(protocol)。 Section=ResponseHeader Detail=CR 必须跟在 LF 之后,在 WinForms 中?

我正在尝试使用WebClient/HttpWebRequest从服务器下载一些数据。我使用以下代码来执行此操作:WebClientclient=newWebClient();client.Credentials=newNetworkCredential("admin","password");Streamdatastream=client.OpenRead("http://routerlogin.com/cgi-bin/CF_logs.html");StreamReaderreader=newStreamReader(datastream);服务器是我的页面,在我的路由器配置中。它在浏