MVC - Opening an asp.net page from the controller - asp.net-mvc

I don't know if this is possible.
Can I have a mvc controller open a popup asp.net page? The asp.net page is within the mvc application, it's basically to run a crystal report viewer.
What happens just now is the mvc view loads and lists reports, then when a report is clicked it launches and exports to pdf. We now want this embedded in a web page instead of exporting to pdf(for various reasons one being no local download of the pdf report).
So sfter reading up i came across the solution to use a folder within the mvc app and use a webform in there. Now I'm trying to find how to open the .aspx pop-up from the controller where the report viewing is initiated.
Does that make any sense.
Any links/help is appreciated

Controllers in ASP.NET MVC are not supposed to open popups. You could do this using javascript inside the view. The window.open javascript function could be helpful:
window.open('/report.aspx', 'report');

Related

ASP.NET MVC Displaying Static Help Website

I'm trying to add Help to my ASP.NET MVC project.
The "help" website contains static pages about the features in my ASP.NET application.
I have added the content for this website into my ASP.NET MVC project and have added a hyperlink that will open the Help in its own window.
However, when I try to access the content, the application attempts to route to the Help controller.
How do I display the help website within my MVC application?
I am not sure you can do this within the context of an MVC application. I would consider just building an empty controller with an Index action (HelpController -> public ActionResult Index()) and just return the view name (cshtml file), shouldn't be any reason you can't rename your static html file to cshtml even if you aren't using razor (although I am not 100% sure without trying that the extension change is necessary). Also I would argue that if this ever needs more functionality you have the scaffolding in place to make non-static mods. Disabling routing within the context of an MVC solution honestly doesn't make the most logical sense. The only other choice would be if you hosted it in a different IIS site (but I don't think I would recommend that unless you have a huge help library).
Use IgnoreRoute when you configre your routing, for example, create a folder "help" in your app's root. Then load it with all your html help files. Then to ignore that route:
routes.IgnoreRoute("help");
You should then be able to access it by http://myapp.com/help/whatever.html

Download pages as PDF In MVC3 Razor

I have a MVC3, Razor engine application having 8 different views(.cshtml).I have these pages for users to enter personal details and other things.I have a requirement to download the content of all these 8 pages(.cshtml) as shown in browser in a button click as a single PDF file and save it.The pages(.cshtml) contains controls like dropdownbox,calender,radio button etc.Some of the contents in the views are loaded from models.
You can try using synchronised pechkin which is available as a nuget package.
This works on html so you can use a templating engine like RazorGenerator to convert Razor views to html.

Using Crystal Report in MVC(ASP.net) application...(Not using *.aspx file)

Any good idea to use crystal report with MVC(ASP.net) application as a normal view like *.cshtml ,instead of *.aspx page.
Ok...Thanks Raphael...So final solution is,
In MVC3 directly cannot use ReportViewer Control from *.chtml page.Can use report in two ways
Create an pdf file on fly from your control class Or
Create a aspx page from where you can show your report using report viewer.
Sample application with crystal report and MVC3 ,can check this.
http://code.msdn.microsoft.com/Using-Crystal-Report-in-bb0e6229
It isn't possible to directly use reportviewer inside razor pages. Here you have a link that gives you 2 workaround
Using Reportviewer Control, within a Razor view, in the MVC3 Framework

ReportViewer in MVC 4 partial

I am still unsure the best way to go about it.
I've read alsorts of resources, yet still no closer to a working solution.
I created a partial ASCX file. Added Report viewer to it, then rendered said partial in my CSHTML file. This was the closest I have come. In that I can see the report viewer, buttons etc. But for some reason the data never shows.
I have tried ASPX page inside an IFrame But this is not the way I want to go, about making this solution work.
Loading an ASPX page outright. But I lose my _Layout.cshtml main page style.
Some people suggest changing all sorts of things in config / Global.asax where as some say its not even necessary.
Ideally I want to have it as a partial in a page. But can deal with it being the only thing on the page, if I keep my main layout.
My experience with the older syntax / pages / non-MVC is limited to this project - trying to get this to work.
My data is linked through the components setup. The connection works fine in aspx page, as single page or iframe. But not in ascx.
The ReportView control requires ViewState to be enabled. In ASP.NET MVC such notion no longer exists. This means that you cannot use this control inside a native ASP.NET MVC view or partial. You can use it only in a classic WebForm (not in an ASP.NET MVC View) and the embed this WebForm inside an iframe within your current ASP.NET MVC view or partial. You have the possibility to render the report as an image for example and directly stream it to the response without using this control. Here's a blog post which illustrates the technique. So you could have a controller action which generates the report as a JPEG image and then link to this controller action from your view using the <img> tag. Unfortunately this makes only a static copy of the report and the user cannot interact with it.
You might also checkout this blog post which illustrates how you could run ASP.NET MVC and classic WebForms side by side.

View in Browser for MVC 3 ASP.NET

In Visual Studio 2010, you can right-click an aspx page in a web forms app, or on the web forms app itself in the solution explorer, and you get "View in Browser" in your context menu.
In ASP.NET MVC projects, this item doesn't seem to be available in the context menu. The only way I know to run the app is to set the MVC app as a startup project and hit CTRL+F5. But, if there are two MVC apps in the solution, this doesn't really work. How do you accomplish this for mvc apps?
In my scenario, There are multiple users working on application on different controllers/view, How could they execute their view without changes the routes in Global.asax ?
This is a fundamental difference between MVC and Web Forms, and is crucial that you "get" this difference.
In Web Forms, everything revolves around the page. You can right click an aspx page and "view in browser" because there is a 1:1 correlation between the page and the URL. The page is at the top of the request, so to speak.
In MVC, everything revolves around the controller. The view is not part of the URL in any way, it's merely a template used by the controller to render the output. You can choose to have any action method render any view you want, it's not tied directly to the request.
Since the "view" is completely disconnected from the request, there is no option to "view in browser", because doing so makes absolutely no sense. You don't "view" views, they are templates that are rendered by the controller action method.

Resources