Arif Sam Arif Sam - 21 days ago 7
ASP.NET (C#) Question

How to open MVC5 view from aspx page

Ive got an aspx file on the root of web application MVC5 project. I can go from Mvc View to the aspx file but im stuck on going back to mvc view. How do i go back from button event in Aspx? Fyi, this is just an empty project as im trying to learn on MVC. So everything is left as it is. Default configuration. The only difference that ive made is add redirect to the aspx page inside Home controller ActionResult.

Folder Structure and redirect code.

Folder structure and redirect code

p/s. If you are wondering why i used an aspx file inside my mvc, im trying to do dynamic rdlc reporting using reportviewer. Im not sure if it could be done using mvc view. As far as i know, razor engine could not use reportviewer and thats why i use an aspx file. Im probably wrong on this as im still very new in doing MVC. Tqvm in advanced.

Answer

Try this:-

First change your current code

public RedirectResult Report()
{
    return Redirect("~/ReportWebForm.aspx");
}

And in your .aspx page, add

Response.Redirect("/Controller/Action")