Search code examples
c#asp.netasp.net-mvcreportviewer

How to open aspx file inside View Folder for MVC5


Ive got an aspx file, containing report viewer and im trying to open the file using controller. If i put the file in the root, it works using redirect but if i placed it in the Views folder, it wont open. Appreciate any help and thank you in advanced for your help.

enter image description here


Solution

  • The ~/Views directory has a directory-specific Web.config file that adds a rule that prevents all direct-access to files in that directory tree.

    To serve WebForms pages in an MVC project you need to move it to another directory that lacks the Web.config rule (e.g. ~/Content), or disable the rule (not recommended).

    Your .aspx file doesn't belong in the ~/Views directory anyway as it is not a View (in the MVC architecture) - it's a "page" :)

    Note that your project will not work in ASP.NET Core as support for WebForms has been removed in that version.