.net MVC deploying on IIS7 Express : Read in embedded resources - asp.net-mvc

My MVC .net Solution has 2 projects:
The actual web project
This is all my models, views, controllers, attributes, etc. Some of the controllers reference my Reporting project, which includes local (e.g. non-server reports) reports that use SSRS and PDF generation.
The Reporting Project
This includes code that will connect to a database and generate the reports. The project also includes a folder that has a bunch of report templates. The report templates are "embedded resources". I have confirmed that they show up in the bin folder of the MVC app when I deploy.
The problem is, when I call the reporting code from within a controller, IIS looks for the report file relative to IIS. In the report code, I might say to look at "report/confirmation.rdlc". This works fine in a console app, however once I deploy with IIS, that path ends up being "C:/program files(x86)/iis express/reports/confirmation.rdlc", which does not exist.
I have also tried "~/report/confirmation.rdlc" to the same result.
I am assuming this means that the home folder (~) is in fact the IIS Express root. How can I change that for the app?

Just try to use Server.MapPath("~/bin/reports/confirmation.rdlc") instead.

Related

how to deploy ASP.Net MVC 4 application on IIS with bin folder

I have tried these steps but could not make it. When I browse my app it shows dll file.
Log onto the machine that is or will be hosting your application.
Use IIS Manager to create a new website for your application.
Create a new application in that site. I believe this also will automatically create an application pool with the same name for you and use it by default.
Specify the virtual directory for your application. This is going to tell IIS where to look for your mvc application. For this case lets assume it is C:\myApp
On your own machine Build the application however you build it with the correct solution configuration (i.e. Release mode). Lets say the result of your build is located at C:\MyProject\bin.
Copy C:\MyProject\bin from your machine onto your hosting machine at C:\myApp
I am a novice to this technology.
you shouldn't just drag the bin folder. it is everything else too like the images, css, jscript files as well as the cshtml files too (your views) to the c:\myapp folder.
or perhaps just do a publish within visual studio. maybe even take a look at this to see if this helps:
How to publish my MVC 3 web application onto IIS7
but generally speaking, I build the solution. I then create the vdir in my IIS. I copy the bin and view folder along with images/css/jscript/shared folders etc... to C:\my deployed site. I then convert to application for that vdir I just created in IIS.
You have to use publish action for ASP.Net web application(MVC, Forms and etc.)

Why does Visual Studio 2012 create content folders for Web API projects?

I find this odd given that a Web API project should really be a view-less MVC 4 Web API based project. Is there any reason for these projects to contain these files by default? I would like to eliminate them all (*.js, *.css, etc.), any reason not to?
These files are included to build the "normal browser" view, this is the page wich you see if you navigate to your host without the "/api" call in your url
You could remove these files if you don't want to use their functionality.

following iterative and agile in asp.net MVC

ok, i know there are a lot of posts online that specify how to do iterations with MVC.
my question is slightly different. when i used to do iterations using WebForms, i was creating one thing only and finishing that one thing till the end which was including the deployment on production.
for example, i was creating a webpage and deploying it, then i create the second page and deploy it. so .dll files were added to my bin folder while the previous dlls remain untouched. at the other hand, when i was making a change latter on, there was this one file that needed to be replaced on production.
now here is the question, how can i acheive the same thing in mvc? beause it just doesn't deploy each page into an individual dll. each time that i add something i have to redeploy the application dll which is not really wise! i played around with deployment options in visual studio but no luck!
There is nothing preventing you from putting controllers and other code in separate assemblies and dropping them in an existing application. Like any ASP.NET based application an MVC application will automatically restart if you add or modify any file in the bin folder or modify web.config.
If you're using Razor you can use RazorGenerator to generate code for your views and compile them into the same assembly.
You may need to write some additional logic though to get routes, model binders etc. wired up correctly.
For a more structures approach to compose the application of separate modules, you may want to look into portable areas. This is an extension to ASP.NET MVC that allows you to package the entire module (including views, css, js etc.) into a single assembly.
First thing, you have to work on the title of the post, it does not match the content of the post.
In asp.net mvc u can choose to deploy only what changed. I.e. If you only changed the .cshtml file, then you can just replace it with the file in production. However if you change any controller class (C#/Vb code), then you will have to upload the web project dll file too so that this new changes are available in the production env

Report Wizard in an MVC Application

After some research, I understand that we can use sql server reporting in an mvc application as long as the view engine is web form instead of razor.
The tutorial I have been trying to follow is:
Creating an ASP.net reporting using Visual Studio 2010
The problem is in Part 2. I cannot find the local classes listed as Data Source. The only choice is to set up a new xsd file to connect to the database. How can I have my reports to use my data repositories as their data source?
The credit goes to TNCodeMonkey!
Not only the project has to be compiled first, we must have an index.aspx file in the root folder of the MVC Web Application.
I don't know why. But the Data source is populated with all my dll's once that magic file is in place.

ASP.NET MVC 3 File Structure

I apologize for the vague title - I am new to ASP.NET MVC coming from PHP, and I have teamed up with a .NET developer that has a webforms background.
When working with MVC in PHP, all of my files are visible on the server - that is to say, I can go into any of my model, view and controller files and edit any of the code remotely without a problem.
In .NET MVC, I couldn't find the controller or model files, so I asked the developer how the webpage is being put together, and he told me about how .NET compiles code into .DLL files and that I am unable to access this. I wanted to view a controller to see how it was pulling together my views, but didn't even see a controller folder on the server.
To me, something about this doesn't sound right, but I am not sure because of my lack of experience in .NET. Can someone provide input as to if this is the typical .NET scenario, and if not, what is he doing wrong? Should I take this as a red flag? Keep in mind that .NET MVC is new to both of us.
Thanks!
There is no code files because these code files was compiled into DLL files during Publish process. It's not strange - it's even better because of performance reasons. It's common scenario for all ASP.NET and ASP.NET MVC applications.
You can deploy yor application via XCopy deployment (to have all .CS files etc.): simply copy all files to destination folder. Then your site will be compiled (into App_temp destination) by runtime on first run. Your .CS files will still be in place.
You can read more about Publishing procees here:
Walkthrough: Publishing a Web Site
Publishing Web Sites

Resources