小编Ako*_*acs的帖子

带有重音+ IE8的ASP MVC3 FileResult - 有问题吗?

如果文件名包含重音符号,则它在Opera,FF,Chrome和IE9中按预期工作.

但在IE8文件类型中是"未知文件类型",并显示"文件"作为文件名(实际上是URL的最后一部分).

有没有人知道解决方法?替换文件名中的"特殊"字符除外?

测试代码:(文件|新项目|添加控制器)

public class FileController : Controller
{
    public ActionResult Index(bool? Accents)
    {
        byte[] content = new byte[] { 1, 2, 3, 4 };

        return File(content, "application/octet-stream", true.Equals(Accents) ? "dsaé.txt" : "dsae.txt");
    }
}
Run Code Online (Sandbox Code Playgroud)

像这样测试: http:// localhost/file, http:// localhost/file?accents = true

编辑=>对我来说是"解决方案",如果有兴趣的话:

public class FileContentResultStupidIE : FileContentResult //yeah, maybe i am not totally "politically correct", but still...
{
    public FileContentResultStupidIE(byte[] fileContents, string contentType) : base(fileContents, contentType) { }

    public override void ExecuteResult(ControllerContext context)
    {
        var b = …
Run Code Online (Sandbox Code Playgroud)

diacritics internet-explorer-8 fileresult asp.net-mvc-3

5
推荐指数
1
解决办法
3662
查看次数

没有T4MVC生成的常量?

为什么T4MVC中没有常量字符串生成代码?我的猜测是编译时复制常量值...

但是,在生成的代码中添加常量将允许在属性中使用T4MVC生成的东西.

我想这样的事情:

插入@line 400:

        public const String ControllerNameCONST = @"<#=controller.ClassName #>";
Run Code Online (Sandbox Code Playgroud)

插入@line 445:

        [<#= GeneratedCode #>, DebuggerNonUserCode]
        public static class ActionNamesCONST {
<#foreach (var method in controller.ActionMethodsWithUniqueNames) { #>
<#  if (UseLowercaseRoutes) { #>
            public const string <#=method.ActionName #> =     (<#=method.ActionNameValueExpression #>).ToLowerInvariant();
<#  } else { #>
            public const string <#=method.ActionName #> =     <#=method.ActionNameValueExpression #>;
<#  }
} #>
        }
Run Code Online (Sandbox Code Playgroud)

所以有人可以像这样使用它:

[SomeAttribute(HomeController.ControllerNameCONST)]
//instead of 
[SomeAttribute("Home")]
//or
[SomeAttribute(HomeController.ActionNamesCONST.SomeAction)]
//instead of 
[SomeAttribute("SomeAction")]
Run Code Online (Sandbox Code Playgroud)

编辑:将其用作模型上的自动完成属性,因此可以在模型上指定"目标"控制器和操作.虽然可以重写autocomplete属性以将ActionResult作为参数而不是控制器+动作名称...

asp.net-mvc t4mvc

4
推荐指数
1
解决办法
652
查看次数

MvcContrib.Mvc3-ci 3.0.75.0突破变化?

刚刚从MvcContrib.Mvc3-ci 3.0.73.0更新到3.0.75,之前工作的普通ViewUserControl引发了一个运行时异常:

The model item passed into the dictionary is of type 'System.String', but this dictionary requires a model item of type 'MvcContrib.UI.InputBuilder.Views.PropertyViewModel`1[System.Object]'.
Run Code Online (Sandbox Code Playgroud)

"冒犯"编辑器从模型中获取一个纯字符串:

<%: Html.EditorFor(m => m.Model.NEV) %>
Run Code Online (Sandbox Code Playgroud)

恢复到3.0.73.0,编辑器再次工作.有任何想法吗?(3.0.74.0似乎也有效)

mvccontrib asp.net-mvc-3

4
推荐指数
1
解决办法
588
查看次数