草庐IT

current-page

全部标签

c# - 测试使用 HttpContext.Current.Request.Files 的 Web API 方法?

我正在尝试为使用HttpContext.Current.Request.Files的WebAPI方法编写测试,经过详尽的搜索和实验后,我无法弄清楚如何模拟它。正在测试的方法如下所示:[HttpPost]publicHttpResponseMessagePost(){varrequestFiles=HttpContext.Current.Request.Files;varfile=requestFiles.Get(0);//dosomeotherstuff...}我意识到有otherquestionssimilartothis,但他们没有解决这个具体情况。如果我尝试模拟上下文,我会遇到H

c# - 在 Windows XP 上,在单个 c : drive 上以编程方式将页面文件设置为 "No Paging File"

我正在尝试编写一个C#/.NET应用程序来优化我们的XP工作站的硬盘驱动器将页面文件设置为“无页面文件”重启运行碎片整理实用程序以优化数据和应用创建一个连续的页面文件重新启动,从Sysinternals运行pagedefrag我真的很纠结#1。我删除了以下键:SYSTEM\CurrentControlSet\Control\SessionManager\MemoryManagement\PagingFiles重新启动后,系统控制面板显示“无页面文件”,但c:\pagefile.sys仍然存在并且正在被SYSTEM进程使用,所以我无法删除它,也无法优化HD。我尝试使用PendingFil

c# - 重写 ASP.NET 代码隐藏文件中的 Page 类构造函数——何时调用?

如果我覆盖System.Web.UI.Page构造函数,如图所示,DoSomething()在页面生命周期方面何时被调用?我似乎无法在任何地方找到这个记录。namespaceNameSpace1{publicpartialclassMyClass:System.Web.UI.Page{publicMyClass(){DoSomething();}protectedvoidPage_Load(objectsender,EventArgse){}}}作为引用,这里是ASP.NET页面生命周期概述:http://msdn.microsoft.com/en-us/library/ms17847

c# - HttpContext.Current.Request.UserHostAddress 为空

在我的开发机器中HttpContext.Current.Request.UserHostAddress为空。为什么?我怎样才能打开它?如果是代理客户端,如何获取Ips列表?WCF服务与ASP.net4window7。谢谢 最佳答案 为避免此问题,您可以解析最后输入IP的HTTP_X_FORWARDED_FOR。ip=Request.ServerVariables["HTTP_X_FORWARDED_FOR"];if(!string.IsNullOrEmpty(ip)){string[]ipRange=ip.Split(',');in

c# - "The breakpoint will not currently be hit. A copy of file was found in dll file, but the current source code is different"

我不断收到此错误消息,提示存在.cs文件的副本,因此不会命中断点。我尝试过清理解决方案、重建、删除obj和bin文件夹中的.pdb文件、关闭VS并重新启动它、重新启动整个机器(这是Windows!有时最复杂、无法解释的问题会像这样解决:\)知道我还能尝试什么吗?这是VS2015上的.net项目 最佳答案 我发现了问题,原来IIS配置为使用我备份文件夹中项目的不同副本。这听起来很傻,但如果有人有类似的问题,我会保留这个问题。 关于c#-"Thebreakpointwillnotcurren

c# - 异步任务中的 HttpContext.Current null

我有一个使用存储库的方法(userRepo):publicoverrideTaskCreateLocalUserAsync(IUseruser,stringpassword,CancellationTokencancellationToken){vartask=newTask(()=>{TUserEntitynewUser=newTUserEntity{Id=user.Id,UserName=user.UserName,Password=password};userRepo.Save(newUser).Flush();returnnewIdentityResult(true);},ca

c# - HttpContext.Current.Cache 是线程安全的吗?

请检查下面的代码:objDDLTable=HttpContext.Current.Cache["TestSet"]asHashtable;if(objDDLTable==null){objDDLTable=newHashtable();arrDDLItems=GetDropDownList("testDropDown");objDDLTable.Add("testDropDown",arrDDLItems);HttpContext.Current.Cache["TestSet"]=objDDLTable;}elseif(objDDLTable!=null&&!objDDLTable.C

c# - 使用最小起订量模拟 HttpContext.Current.Server.MapPath?

我正在对我的家庭Controller进行单元测试。在我添加保存图像的新功能之前,此测试运行良好。导致问题的方法如下所示。publicstaticvoidSaveStarCarCAPImage(intcapID){byte[]capBinary=Motorpoint2011Data.RetrieveCapImageData(capID);if(capBinary!=null){MemoryStreamioStream=newMemoryStream();ioStream=newMemoryStream(capBinary);//savethememorystreamasanimage//

c# - LinqToSQL 错误 : Operation is not valid due to the current state of the object

在更新命令期间,我收到以下错误:Operationisnotvalidduetothecurrentstateoftheobject我试图从更新命令中删除一列并且它工作正常。此列是一个FK,与其他工作正常的FK相似。这是执行更新的代码:ti.NumeroTitolo=titolo.Numero;ti.RKTipoTitoloGenereTitolo=titolo.RkTipoTitoloGenereTitolo;ti.RKBanca=titolo.RkBanca;ti.DataScadenza=titolo.DataScadenza;ti.RKTipoEsito=titolo.RkTi

c# - 扩展 ASP.NET 身份角色 : IdentityRole is not part of the model for the current context

我正在尝试在我的MVC5应用程序中使用新的ASP.NETIdentity,特别是我正在尝试将ASP.NETIdentity集成到现有数据库中。我已经阅读了有关DBFirst和ASP.NETIdentity的SO问题/答案,并且遵循了所有建议我仍然无法向我的数据库添加角色,尽管我在添加用户时没有问题。这是我的代码:varcontext=newPayrollDBEntities();varroleManager=newRoleManager(newRoleStore(context));boolroleExists=roleManager.RoleExists(roleDto.Name);