How do i host classic asp files within MVC application - asp.net-mvc

Is it possible to render classic asp files from within my MVC application?
I have an application which lives at
http://localhost/myMVCapp/
and i put the asp files within a subfolder off the application root
i.e.
http://localhost/mymvcapp/asp/news.asp
I keep getting 500 errors if i try and request the file.
I believe i need to supply a web.config within this folder which allows the request through but i am unable to workout the correct settings.

I think you can Convert your folder to web application and then you should write your own Route.

Related

how to set default document in web.config file in ASP.NET MVC application..?

I'm working on ASP.NET MVC application it is working fine now i want to host it on IIS server, I'm doing this as generic procedure when I'm opening it on browser that time it showing all directories list what now how can set my default action in web.config file.
You don't set a default document with MVC. There's no such thing as documents in MVC, let alone a default one. If you're getting a directory listing instead of your app being loaded, then there's some problem with your setup. Most likely, you don't have it as an actual application in IIS, but just a virtual directory

Where to store public images in an ASP.net MVC Application?

I'm quite new to the MVC Framework.
I have images I want to be able to be accessible with an absolute URL. I was told to create /images under /Content. I try to navigate to http://myapp.net/Content/images/img.jpg, and I get a 404.
Perhaps I don't know what the external URL is to get to that folder? Would there be any settings I need to set - in web.config? In IIS? (Actually, I'm running the app off VS 2013).

Hosting an MVC and a webforms site on the same IIS7 instance - web.config inheritance

We have a website that was written in classic ASP, then I started to extend it using web forms. These extensions exist in a subfolder of the main folder. Now we've decided we'd prefer to use MVC3. Also, as we'd like to convert all our site to MVC3 over time, we are hosting the MVC code in the application root. I've found some other questions where people have a similar issue to mine, but no solution. The issue is simply that my web forms app can't seem to be stopped from inheriting the web.config settings from the root folder, and as a result, it won't run, it either complains about missing dlls, or complains about running the wrong version of .NET, or complains I need to remove some settings ( which I try and can never get to work right ). The app in the subfolder is also hosting a webservice that is called by our application, and it also runs HTTP handlers to protect our imaging content, so it's got a bit of stuff in it. Do I need to run my MVC site in a subfolder ? Is there any way to have MVC in the folder above a web forms app ? I'd prefer to set things up so they share session data, but that's looking likely to be impossible at this stage...
So to be clear the folder structure is:
<root>
contains asp site and MVC site.
<subfolder>
contains webforms application
</subfolder>
</root>
and my issue is getting the subfolder to run, preferably in the same session as the MVC app.
There is no reason you can't run regular .aspx files on an MVC site. You are correct though, web.config settings are inherited from the parent (chain), but you just add a new web.config in your directory with relevant settings.
What you will have to do is play with the routes, because by default MVC will route all requests into your controller classes. But if you google around its fairly simple to add an exception to the routing.
If you post some of the specific errors we can probably help further.
Oh and do you mean Classic ASP? i.e. not Classic ASP.NET? Because you'll have fun sharing session data between ASP & ASP.NET.

asp mvc 2 route all requests to files in specific folder to given controller/action

Can't make this work fast. I have a folder in which I have text files.
And so if user requests some file like mysite.com/thefolder/file.txt he sees the contents of the file.
What route should I register so that all requests to anything in the folder would go to mysite.com/Error/NotAllowed action?
IIS will, by default, serve all .txt files directly without even going to the ASP.NET handler, which handles routing and MVC.
To change that behaviour, you will have to change your IIS settings or change the routing rules at any firewall/load balancer you have in front of it.

ASP.NET MapPath to the root of the Solution

I'm having trouble selecting the root of the solution in my ASP.NET Application.
I have three applications inside this solution, a Web app, an API and an app for Reports. I was trying to select my Reports app from the Web app in code using Server.MapPath but I can't get to the folder.
I tried Server.MapPath("\Tagus.TMS.Reports/Media/VoyageControlReport.rpt") from inside the web app.
How can I get that app path?
The Server.MapPath will use the "application level of IIS" to determine the path returned.
So the path returned is the physcial location of the root of the application (web site) + what ever parameter you pushed into the "MapPath" method.
I would advise you to make a "/Data" directory in your website and use the "Server.MapPath("/Data/dataFileToLoad.rpt") to get the physcial path.
It also gives you a nice isolation for your data files (rpt) versus your runtime files (dll's).
Hope this helps,

Resources