combine asp net projects and mvc3 in one single solution - asp.net

I am facing a problem with adding two projects in the same solution and both run as a single instance.
Let me explain that in more details. I have MVC project which is the main web application I used in my project now I want to add a new asp.net application to use for rendering reports and get the benefit of using asp.net page with Report Viewer.So, I was thinking in adding a new asp.net application that will contains my reports then map this new pages to my mvc application
The problem is how to deploy these two instances as one application in server.
I know that i can run both applications in debug mode by using debug > start new instance but how i can manage that in server.
Also is there is a way to deal with those two applications as one application
Update:
Using Ihor idea and with the help of this tutorials
How can I use a reportviewer control in an asp.net mvc 3 razor view?
http://msdn.microsoft.com/en-us/library/ms251692%28v=vs.100%29.aspx
I am facing a problem in binding to my object datasource attached to project. For example I have repository for SalesInvoices and I want to use GetData function exists in that repository to bind report with

ASP.NET MVC is built on regular ASP.NET Web Forms. In your scenario you don't need to have a specific different project for Reports, you can have Reports inside your MVC project. For example you can add a new GenericReport.aspx under some folder (for example "Reports") of your MVC project.
Then when user requests some action on your site you can use PartialView with iframe to your GenericReport.aspx. On this page you can add any webforms-specific logic that you need.
To be honest I am not aware of such particular behaviour of reports, but according to the reply: How can I use a reportviewer control in an asp.net mvc 3 razor view? you will probably need to move your data to a separate project. It shouldn't be web application project but a class library (generating .dll) and you can use it in your MVC project.

Using Ihor idea and with the help of this tutorials
How can I use a reportviewer control in an asp.net mvc 3 razor view?
http://msdn.microsoft.com/en-us/library/ms251692%28v=vs.100%29.aspx
I was facing a problem as I noted in updates in original post I solved by adding a class in reports folder contains method with my model Like that
public class ReportModels
{
public List<SalesInvoice> GetData()
{
return null;
}
}
with this way i can map this model to report successfully

Related

Why CRUD razor pages in ASP.net CORE does not work out-of-box after Scaffolding with Database-first approch?

in VS 2019 i have created an web-app like this:
After that i have:
Created a database, and added it in VS2019 "SQL server explorer" (so connection is fine)
Then Scaffolded according to the command in the lasted post here: https://github.com/dotnet/efcore/issues/19986, and i get my "class/model" as a result of this.
Then I add my CRUD pages like demonstrated in this video: https://www.youtube.com/watch?v=q2u1VY28Drs
And that is ok, since the CRUD pages are created (Exists in solution explorer).
Now when i start the app, and manouver to the new CRUD pages as shown i the last video link, it does not work out of the box, the page does not exist: No webpage was found for the web address: https://localhost:44335/V2/index. I dont understand why, but suspect it has something to do with routing.
Or, what could be the problem here?
tnx
Updated 19.10
I create a MCV app, and follow the steps 1&2 above, then i follwo this guide at the "Add model" step: **https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/?view=aspnetcore-3.1 ** and
then add this: using Microsoft.EntityFrameworkCore; in my startup file. I do not add using MvcMovie.Data;
And it still do not work, the documentation is lacking to be mild on the database first approach. What do i NEED to do from the step: "Add a Model" in the MVC guide? anyone?
Or, what could be the problem here?
The key of this issue is that the project in this video is in asp.net core razor page rather than asp.net core mvc.
When you create the project, in Create a new ASP.NET Core web application box ,you should choose the template of Web Application, you can have a look for official documents:
Then you can follow the video operation to create the crud pages.
If it is in the asp.net core mvc project, you need to create New scaffolded Item in the Controller folder and should select MVC Controller with views, using Entity Framework template, you can have a look for this.

How to Implement MVW Pattern in existing asp.net web form application

I am working on asp.net web form application which is consist of aspx(html), code behind and JavaScript code. Now we want to upgrade our application into new technology using asp.net MVW (Model View Whatever) pattern but the base line is that the new pattern should be integrated in existing web form application so that the existing old web form should work as is and new screens will be implemented using MVW pattern, it will be consist of (Model, View, WebAPI & AngularJS)
My questing is it possible to implement MVW pattern in existing web form application! so that we can run two different approach (existing web form and MVW) under single web application.
I googled for such application sample but I found example only new webform application using the MVW pattern with no code behind of web form, I need the existing web form should work as is and new screen (pages) should be develop using new pattern.
Please help me if any one has link for such type of example.
As the paradigm of model view whatever (MVW) adhere strongly to SPA and modular style programming with no postbacks of pages. If you read the documentation of angular which states that it works on MVW architecture I don't think that you can achieve it in web forms or it is not possible. Even if you take ASP.NET MVC it's hard to fit webforms with it.As Currently, we are going thru that transition phase.
You have to decouple the logic from tight bindings of web forms and make it modular by using web API and angular.
Hope It helps.

How to add a MVC Account controller to WebApi project in Visual Studio 2013?

I am trying to understand the concept of one asp.net. I did the entire exercise here.
Its easy.
Now trying to understand further, I created a new Asp.Net project and selected Web API template as follows. So we see that MVC and Web API check boxes are selected.
If I observe the project The AccountController is an ApiController and so the views folder does not have any Account and Manage folders as expected.
Now my question is how do I add an Mvc Account controller to the above project? I very well know that if I select MVC in the new project dialog as follows I can get that.
What I want is to add is an MVC account controller along with the views exactly like the following in the Web api project show earlier.
This should be very easy I guess. So could someone please describe some steps? Like for example, which model and context we need to select on add scaffold and then Add Controller dialogs?
In other words I want to understand looking at a controller say AccountController be it Api or Mvc, how do I understand what is the model class and Data context associated with it.
The plenty of scafold templates that exists are very useful to have an application running. Even you can create a new WepApplication project and add the Nuget package AspNet.Identity Sample, wich has a lot of features.
However for your project, I recommend you to start with and Empty Web Api project and then start adding only the stuff that you need. This way you will understand better how your Wep Api works with AspNet Identity (Account Management, External Login Providers like Google or Facebook, ...).
This Step by Step tutorial (and the next series) will guide you in implementing and understanding the Web Api and AspNet Identity starting from an Empty Web Api project.
Hope this helps.

Importing an ASP.NET website application to views in an MVC application

I have created an ASP.NET website with several aspx webpages and a masterpage. I now want to port this website to an MVC application and use the aspx pages as views. How can I do this in Visual Studio 2012?
There is no automatic process you can use to do this. You will need to create the views/controllers/actions manually and cut/paste your existing code into these (unfortunately)
Their is no one click process. You need to do it manually.
I suggest you to create a MVC solution. put your logic in Models, And start rewriting Controllers and Views according to your previous asp.net apps. Because asp.net MVC 's rules doesn't allow Session and Viewstate you need to make changes to your existing apps.
You need to move from session and Viewstate if your current asp.net app use this things.

Posting data from mvc view to a webform in the same MVC project

I have an MVC project that needs to use SSRS for reporting. For this reason my MVC project now has a webform that holds the reportviewer control. From my MVC page I now need to pass certain parameters to the webform. What is the recommended way to do this? I’m not sure I want to use sessions for this purpose unless it is the recommended way. How do I post from the mvc view to the web form? I don’t think I can call it by controller name as the web form has no controller.
Please help.
In the past, I have maintained a legacy system that used the webform for report generated and an ASP.NET MVC in the new pages. I found out only one way to do that is using the Session to communicate between the webform and the ASP.NET MVC pages. So any other approaches will be welcome :)

Resources