asp.Net   发布时间:2022-04-07  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了asp.net – HttpContext.Current不解析在MVC 4项目大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想使用ImageResizer(从ImageResizing点网)。我通过NuGet为MVC安装ImageResizer。但是当我去使用下面的代码从示例:
//Loop through each uploaded file
        foreach (String fileKey in @R_674_10107@Context.Current.request.Files.Keys)
        {
            @R_674_10107@PostedFile file = @R_674_10107@Context.Current.request.Files[fileKey];
            if (file.ContentLength <= 0) conTinue; //Skip unused file controls.

            //The resizing setTings can specify any of 30 commands.. See @R_674_10107@://imageresizing.net for details.
            //DesTination paths can have variables like <guid> and <ext>,or 
            //even a santizied version of the original filename,like <filename:A-Za-z0-9>
            ImageResizer.ImageJob i = new ImageResizer.ImageJob(file,"~/uploads/<guid>.<ext>",new ImageResizer.ResizeSetTings(
                                    "width=2000;height=2000;format=jpg;mode=max"));
            i.CreateParentDirectory = true; //Auto-create the uploads directory.
            i.build();
        }

foreach中的“@R_674_10107@Context.Current.request.Files.Keys”不能解析?我有我的正确使用和Visual studio不提供“Resolve”选项。

解决方法

问题是Controller类有一个名为@R_674_10107@Context的公共属性(见 http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.httpcontext.aspx)。

这意味着,当您尝试在控制器中使用它而没有任何限定时,它将解析为本地属性,而不是System.Web.@R_674_10107@Context。属性的类型是@R_674_10107@ContextBase,它有一个request属性,它会做你想要的(但请注意,它不是你从System.Web.@R_674_10107@Context得到的相同的类。

大佬总结

以上是大佬教程为你收集整理的asp.net – HttpContext.Current不解析在MVC 4项目全部内容,希望文章能够帮你解决asp.net – HttpContext.Current不解析在MVC 4项目所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。