Can ASP.MVC 3 run in a site root and allow other ASP.Net apps to run in subfolders? - asp.net-mvc

Can I have an ASP.MVC 3 application running in my site root (a simple CMS to provide MOST site content), and have it co-exist with additional ASP.Net apps (2 Web Forms apps and 1 MVC app) running in subfolders to provide more specialized functionality?
Example:
www.mycompany.com
/ // ASP.MVC 3 App goes here to handle 90% of our page content.
/store/ // Older web forms app to handle our online store.
/survey/ // Older web forms app to provide survey forms.
/locations/ // An ASP.MVC 3 app to render a map with site locations.
I wouldn't mind integrating the 'locations' MVC app with the CMS if necessary, but if they can be separate, it would simplify long term maintenance. Does the root application need to know about the others? (including the other projects as subprojects into the main MVC project in VS.2010?)
As for the 'store' and 'survey' Web Forms apps. They are running .Net 3.5, but we could recompile them to 4.0 if needed. Do the 'store' 'survey' and 'locations' folders need to be virtual folders mapped in with IIS?
Hopefully this example is simplified enough, to find out if it is possible (and how) to integrate applications together with ASP.MVC 3 running in the site root. I'm in a situation where the separate apps must share a domain and pretend to be 1 cohesive site. (They will all share the same HTML template)

Just mark those other applications as Applications in IIS and that will do.

Not directly -- you'll be fighting nasty IIS battles all week methinks. You might be able to get there eventually but it won't be pretty. There are two potential approaches here:
a) Put the entire thing behind a reverse proxy that passes traffic to the appropriate server (or virtual server). Downside is you might have to do a little tom-foolery to convince IIS that your store is running at http://www.example.com/store instead of http://localhost:666/store but it is doable.
b) Try and incorporate the old webforms apps into your MVC cms app. Really depends on lots of specifics but could be as easy as setting the route to be ignored and tweaking config as appropriate.

Related

Is it possible to integrate two .NET Applications (1 WebForm and 1 MVC) into one domain

I originally programmed two separate. NET applications (1 WebForm and 1 MVC 5) that originally were going to be on separate domains. I'm now trying to integrate both applications on a single portal on a single domain that will likely be a MVC Web Application. Ideally I would like to use subdomains to keep them separate.
I've figured that there's 2 options to make this happen but even then I don't know if #1 is even feasible.
1) Host each application on separate subdomains (ex: WebForm.domain.com and MVC.domain.com) while having the main portal on the default domain (domain.com).
2) Rewrite the WebForm application into a MVC application and just merge the two projects.
I'm open to any and all suggestions

Offline and online application using asp.net mvc

brief history of my project:
2 versions of application, one running in windows form, another running in the web using asp.net
current task: to revamp the project to use asp.net mvc 4 to use only one version of code base.
In final product, there will no more windows form; but only the asp.net mvc. this is with regards with short development timeline.
concern:
my concern is for offline users.
maybe i can host the asp.net mvc4 offline using localhost and sql lite.
When offline users click on check update, there will be able to get the latest version of asp.net mvc 4 ?
any other better solution that is feasible ? i prefer the architecture fits the vb.net
Have you take a look at SPA. That kind of projects, by nature, can work in online and offline mode. One thing to take into account is the ammount of data that the offline mode should handle (most SPAs are using the local storage for offline use, which is a little small)
By looking at this site you will find a lot of resourses on SPA.
http://www.johnpapa.net/spa/
Deploying MVC app with Sqlite in localhost will be quite a challenge in term of maintenance. Maybe you can develop HTML + jQuery solution which can run locally on client system and make use of client cache to hold the temp data. Also it can interact with live app by making ajax calls.

Database driven asp.net MVC application

I have a CRUD application written in Classic ASP (not .net) which transfers (routes) page requests to relevant servers using a loadbalancer DLL.
It works like this:
Someone requests for www.mywebsite.com/products
There is an index.asp under folder products that redirects the request to either:
http://www1.mywebsite.com/products
or
http://www2.mywebsite.com/products
based on a loadbalancer logic.
Another scenario:
Someone requests for www.mywebsite.com/products/details
There is a index.asp under the sub folder details within the products folder that redirects the request to either:
http://www1.mywebsite.com/products/details
or
http://www2.mywebsite.com/products/details
based on loadbalancer logic
The main issue with application is whenever I include a new page, I need to create a folder and index.asp page to redirect the page.
We have a CMS database which contains the details of all pages. So I want to create an MVC application to replace the existing Classic ASP application.
But I didn't find any database driven MVC applications and I'm bit confused by routing. Do I need to create a separate route for each main folder I have or should I create a generic route for all pages.
Any help would be appreciated.
You don't have to migrate to ASP.NET MVC just for the URL rewriting.
IIS 7 does have an integrated URL rewrite module and ASP.NET 4 includes routing as well.
IIS URL Rewriting and ASP.NET Routing
URL Rewriting in ASP.NET
Anyhow, if you search e.g. on Codeplex for ASP.NET MVC projects, you'll find a lot of them which are database driven.
You don't need to create individual routes for each seperate item. Think about the concept of querystrings (?id=15&day=monday). URL rewriting is pretty much the same.
Update
I've overseen that your talking about classic ASP.
The build in URL rewrite module in IIS 7 works also fine with classic ASP. If you are having an older IIS version you need a 3rd party ISAPI rewrite module.
Anyhow, switch it to ASP.NET MVC ;)
MVC would lend itself very well to sorting your routing problem. So would ASP.NET 4.
However, the problem you have is that you don't know enough to ask a precise question. Hence your confusion with routing in MVC.
I would therefore suggest reading the nerddinners tutorial. You can get a PDF download for free. To go a step further, read Stephen Sandersons book on MVC 2 (or MVC3 in a couple of months).
If you follow the nerddinners tutorial and Stephen Sanderson's tutorial, that will give you a better idea of how it works.
In short, this is how MVC works:
In MVC, you forget about files and folders.
Instead, you have Controllers and actions. The routes map the requests to the right controller and action.
The code in the actions then decide which View to stuff full of data (from a database or wherever, it doesn't matter). The Views are just templates that are told what to do and what data to display.
The Controllers ask the Model for the data that they want.
Ie, the data access is all done in the Model, neatly separated from the User Interface.
M: Model
V: Views
C: Controller
The above is probably meaningless to you. It is a VERY different mindset to ASP classic.
If you are coming from old ASP, you will have a long hike, but it can be done. I came from Access. Anyway, read the books, follow the tutorial and see if it is for you.
When you are ready, we will still be here to help with more precise questions.
Asp.net MVC routing in your migrated application
Based on requests you've shown here you can sort everything up with just default route:
{controller}/{action}/{id}
In your case you'd have a ProductsController with all the actions you need.
Load balancing application
But having an Asp.net MVC application is just one part. This application will run on both load balanced servers. All redirecting should be done before they hit the MVC application.
If you intend to continue using the same loadbalancer DLL you could create a different Asp.net MVC application with only one route definition:
{*path}
and a single controller and action that does it all:
public Load: Controller
{
public ActionResult Balance(path)
{
// decide for web server and attach path to subdomain
}
}
This should do the trick just fine as long as the overhead of this action is very small. Otherwise your load balancing logic will become the bottleneck of your application since all requests go through this load balancer (it does that now as well so bare in mind this is no different now; never mind the authentication process on different subdomains you may be using).
Load balancing alternative
You should consider using the web farm balancing capabilities on the IIS 7 that will run your application on several web servers (because that's what your load balancing does in the first place). Search the web for web farm information. You can start with this:
http://www.iis.net/download/webfarmframework

Windows Azure & ASP.NET MVC site deployed on it?

is it possible to deploy asp.net MVC site on windows AZURE platform? I understand we can deploy a WCF service, but what about full site? Will it work? Will it scale (i.e. load balance)?
We're having a project to develop - a donation site, which will be advertised a lot and will receive a lot of traffic. I do want to try AZURE, but is it possible for AZURE to run the full asp.net mvc site?
Yes - you just need to make sure that MVC dlls are copied to bin folder and MVC project is added as a web role.
Here's a tutorial.
Also take a look here:
MVCCloudService
PS. Remember about Azure prices.
As others mentioned, MVC2 sites are totally OK for Azure. Your second question: will it scale (auto-balance) needs more explanation:
If you have more then one compute instance (VM) allocated to your application, MVC2 site will auto-balance provided you haven't made any mistakes with keeping session-information inside the URLs.
However, if you want to automatically adjust the number of compute instances per load on the site, you will either have to write the scaling logic yourself (check this site to get started http://convective.wordpress.com/2010/10/12/autoscaling-in-windows-azure/ ) or use a third-party scaling engine like # http://www.paraleap.com/
HTH

Is it possible to host an ASP.NET MVC2 website from a windows service?

I have a .NET 4 application that runs as a windows service. It runs periodic tasks and provides WCF restful webservices. It already hosts a silverlight web page (via WCF) that allows a user to configure the service.
Now I have a requirement to provide information on HTML/java script pages (e.g. for browsers and platforms that don't support Silverlight). I can serve simple HTML and javascript pages through WCF but that becomes laborious very quickly. I'd like to use MVC2.
Is it possible to provide MVC2 web pages from within a windows service? Or at least use some of the functionality provided by MVC like routing and the view engine?
Or is it more trouble than it's worth and should I head down the path of a separate app hosted on IIS?
You can host the ASP.NET runtime in any type of application including a Windows Service using the CreateApplicationHost method. Although note that by doing this you lose the robustness, security, logging, etc... that a real web server such as IIS provides.
Since you're asking the question about what route to take, I'd host an MVC2 application in IIS. Why recreate a web server using WCF when IIS is already there - and since you're asking, it sounds like that's a viable option.
I agree with Darin's answer that you can host ASP.NET MVC2 in any application, but I think you're going to end up recreating a lot of plumbing that's already in place with IIS.
On the upside, if you go with serving up ASP.NET MVC2 resources in a WCF service application, it may end up rocking and you could have a nice application you can sell on the side. :)

Resources