类型'mvcExampleOne.Controllers.FileUploadController'已经定义了一个名为'File'的成员,其参数类型为WHY? [英] Type 'mvcExampleOne.Controllers.FileUploadController' already defines a member called 'File' with the same parameter types WHY?

查看:58
本文介绍了类型'mvcExampleOne.Controllers.FileUploadController'已经定义了一个名为'File'的成员,其参数类型为WHY?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public class FileUploadController : Controller
   {
       //
       // GET: /FileUpload/

       public ActionResult File()
       {
           return View();
       }
       [HttpGet]
       [Actionname("File")]
       public FileResult File()
       {
           return new FilePathResult("~/Files/Document.pdf", "Application.pdf");
       }





这里我的目的是创建一个可下载的文件,但是当我构建项目时,我得到了以上指定的错误?即使我提到[HttpPost]和Actionname属性为什么?如何解决这个问题?帮助我提前感谢



Here my intention is to create a downloadable file but when i'am build the project i'am getting the above specified error? even i mentioned with [HttpPost] and Actionname Attributes why?how to solve this? help me thanks in advance

推荐答案

您定义了两个具有相同名称File()的Action Result方法。

重命名之一他们。

You defined two Action Result methods which have the same name "File()".
Rename one of them.
[HttpGet, [ActionName("File")]
public FileResult FileGet()
{
   return new FilePathResult("~/Files/Document.pdf", "Application.pdf");
}


这篇关于类型'mvcExampleOne.Controllers.FileUploadController'已经定义了一个名为'File'的成员,其参数类型为WHY?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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