MVC ActionResult返回文件“未定义” [英] MVC ActionResult Return File "Undefined"

查看:89
本文介绍了MVC ActionResult返回文件“未定义”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的MVC 4  RC应用......仅用于测试...

I have a very simple MVC 4 RC Application... Testing purposes only...

在我的_Layout.cshtml文件中,我有以下帮助...

In my _Layout.cshtml file I have the following Helper...

@ Html.ActionLink(" Get File", " GetFile",Home)

@Html.ActionLink("Get File", "GetFile", Home)

在我的HomeController中,我有以下内容(这是直接来自PluralSight视频):

In My HomeController I have the following (this is straight from the PluralSight Video):

public ActionResult GetFile( )

public ActionResult GetFile()

{

  return File(Server.MapPath("〜/ Content / Site.css")," text / css");

  return File(Server.MapPath("~/Content/Site.css"), "text/css");

}

public ActionResult GetIt()

public ActionResult GetIt()

{

  FileStream fs = new FileStream(Server.MapPath("〜/ Content / Site.css"));

  FileStream fs = new FileStream(Server.MapPath("~/Content/Site.css"));

 返回文件(fs," text / css");

  return File(fs, "text/css");

}

这两个都返回"未定义"到浏览器。一些新手问题......首先,为什么?文件结果有15个重载我测试了这两个,我得到了相同的结果...我希望它下载的行为并在客户端上的相应应用程序
上打开文件...就像视频示例。第二个问题...我如何确定错误发生的位置...我在控制器中设置了断点,但没有错误......多个浏览器返回相同的东西......"未定义"。

Both of these return "undefined" to the browser. A few newbie questions... First, Why? There are 15 overloads to the File result I tested these two and I get the same result... The behavior I want it to download and open the file on the appropriate application on the client... Like the video example. Second question... How do I determine where the error occured... I have set breakpoints in the controller, but there is simply no error... Multiple browsers return the same thing... "undefined".

有人可以协助吗?

ME

推荐答案

ASP.NET MVC论坛
http://forums.asp .net / 1146.aspx / 1?MVC
是解决此类问题的最佳地点
The ASP.NET MVC forums http://forums.asp.net/1146.aspx/1?MVC is the better place for such questions


这篇关于MVC ActionResult返回文件“未定义”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆