Running MVC and Umbraco 4.7 applications in parallel - c#

We are using Umbraco 4.7.1 and it's very slow sometimes, taking more than 10-14 secs to load certain web pages.
Is it possible to create a new MVC web application and use this to display the slow pages instead of Umbraco? The important thing is that it should run on same web server and should replace a specific path currently existing in Umbraco, e.g. http://127.0.0.1/Product.
Any suggestions how to improve the performance are also welcome.

There are two parts to the answer. Firstly, yes you can. You can host the MVC application as an application within the site in IIS. You will need to ensure that you override all the web.config settings as these settings will be inherited. You will also need to add an the path of your MVC application to the umbracoReservedUrls and/or umbracoReservedPaths appSetting in the Umbraco web.config.
However, the second part of the answer is: don't.
Do not create and host a separate MVC application purely because you have performance issues in your Umbraco application. Figure out what is causing the performance issues and fix it. It sounds like you are possibly making too many calls to the database, or the calls that you are making aren't optimized.
My advise would be to run SQL profiler over the site on these pages and check what is happening. You should then review the indexes on the non-umbraco elements of your database, using views where appropriate, and also review whether you are using appropriate caching.

Related

What’s the benefits of Asp.net MVC projects precompilation?

My ASP.NET MVC project is taking more time than usual on the first hit,and it gets better afterwards, but the response goes slow again every next day. so It's a continuous performance issue
I googled the issue and most of the solutions are choosing precompilation during publishing, but Microsoft officials seemly didn’t confirm the operation can result in fast startup time for every request at any time.
So what exactly are the benefits of ASP.NET MVC Precompilation? Please advise
You can basically find the information here, there is also a fair amount of other relevant information on the advantages
ASP.NET Web Site Project Precompilation Overview
Precompiling an ASP.NET Web site project provides the following
advantages:
> Faster initial response time for users, because pages and code files
do not have to be compiled the first time that they are requested.
This is especially useful on large sites that are frequently updated.
A means to identify compile-time bugs before users see a site. (You
can also accomplish this when you compile a project in Visual Studio.)
The ability to create a compiled version of the site that can be
deployed to a production server without source code. This makes sure
that that people who have access to the production server will not be
able to view the source code.
You can also find similar questions here
What is the advantage of the ASP.NET precompilation?
What effect does the new precompile during publishing option have on MVC4 applications?
And some related information here
Precompiling Your Website (C#)
Because the pages must be automatically compiled when they are first
visited, there can be a short but noticeable delay when an ASP.NET
page is requested for the first time after being deployed.

How to publish an ASP.NET MVC 4 project in a specific url

I'm in a situation that I do not know how and I do not know if it's possible to do.
I have a website in ASP.NET MVC, let's call kelvinsite.com.br, this site is a asp.net mvc project.
And I also have another site, we'll call kelvinproject.com.br, this site is another project aspnet mvc.
What I want to do is publish the site kelvinproject.com.br inside the project kelvinsite.com.br without merging the web projects in the same project in Visual Studio, I want both to stay separate in the same solution.
So the url would be:
http://kelvinsite.com.br/kelvinproject
Is it possible? What is the name of it?
It's possible, but there's some potential pitfalls depending on how you've defined your URLs. The term you're looking for is "sub site" and it usually requires some work in IIS. You could do something similar with ASP.NET MVC Areas, but you're not really packaging the apps separately in that case.
There's a pretty good discussion on subsites here: Sub-Website in IIS - ASP.NET
Basically, you deploy the app to a subfolder of the parent app on IIS. Configurations get carried down, which means you might have to change the web.config on the child to remove parent entries, etc, depending on things like .NET versions of each, etc.
You should be able to publish each site completely independently. There are only two major things to keep in mind on the server.
1) Make sure that the directory, kelvinproject, is marked as an application in IIS.
2) You may need to adjust the web.config in the main application so that it's settings aren't inherited by any child applications. You can easily do this using the element of the web.config. There's a good example of this at: Scott Hansleman's blog and it's pretty simple. Just put things like and within this location and it won't be inherited in the new application.
Don't think of them as a specific site. Each one is a sepeaate web application and technically they don't know anything about each other, and don't care about the other. You can have 50 projects in the same solution and it doesn't matter to any of them where the others are published.

ASP.NET Completely modular design - how?

Technology: ASP.NET 4.0, C#, forms/mvc
I am a .NET web designer and I wish to create a modular based website for people, similar to what DNN does (but I want to create my own cut down version).
The idea is that I create a base website that can 'activate' features which the client needs (and has paid for). These features may be used by many clients which require frequent future updates for all clients (so I wish to keep upgrade time down to a minimum).
For example, I upload the base web application using web deploy and it sets up the core database tables/views/SPs in the process.
Then I login into the website as developer and activate the out of the box features that I wish to permit the user to take advantage of.
The only way I can think of currently is via user control, resources etc..
But I need a little of your experience and advice over what the possibilities / dangers are....
e.g. images for an application e.g. blog, that I have activated for a client - how do I reference those images
e.g. Can user controls be dynamically added to a web application (which is pre-compiled unlike a website - it must be a web application since I am using web deploy).
e.g. Modification of web.config to add additional routing (doesn't matter if app has to go down to do this).
The idea is that I can upgrade websites features en-mass, rather than manually enhancing each individual website which given a certain amount of clients would result in an awful amount of time lost.
I do not have access to sharepoint (nor do I intend to).
Any advice on how to automate modularity completely via a front end in asp.net would be superb!
My main problem is how to reference files and resources outside of the websites directory and without using virtual directories (ideally - but open to suggestions).
Thanks,
Dan.
I would suggest that your idea sounds like an ideal scenario for WebParts. There are lots of resources on how to go about building a WebPart management structure from scratch. Then, in terms of your 'bulk update' facility, it would simply be a case of tweaking database entries that are used to configure which web parts a user sees.
I'd be interested to know what you decide to do.
Best
Ian
Try a Multi-Tenancy Architecture as you can find some good info here :
http://codeofrob.com/category/10.aspx
http://weblogs.asp.net/zowens/search.aspx?q=Multi-tenant+ASP.NET+MVC+%E2%80%93&o=Relevance

ASP.NET: Creating versions of the same website

My new assignment at work is to create a second version of our existing web application. Currently, our application supports only full time brokers, but now we our launching a second site specifically for part time brokers.
The new site will be almost identical to our existing site with the following exceptions:
It will have it's own branding.
A couple of the user controls used for displaying information will be different (but none of the pages will be different).
Our existing users should not have access to the new site and vice versa.
It needs to be easy to test both versions of the website from within Visual Studio easily.
We want to reuse as much our existing code as possible.
I have 2 weeks to do this.
I'm hoping that this is a common scenario and someone out there has some advice for how to accomplish this.
I really, really don't recommend branching projects or other routes which involve copying what is essentially identical code with the exception of branding and authorization. It will certainly be easier in the short run but, as you said, will become a nightmare very quickly trying to maintain almost-identical code bases.
Your pages can make the decision on what controls to show based who is logged in or even set globally to indicate this is the part-time broker version of the application. You could have a set of views and light logic to handle part time vs. full time brokers. Since the sites are deployed separately, a config setting would be straightforward. If you have other versions of the same site, you may have to give this some thought to ensure it would scale with your other variations.
I would even use the same database as long as you can separate the data appropriate using claims-based (preferred) or role-based authorization or similar.
All this said, there does not seem to be any great reason why you'd want to deviate from using the same code base.
I would create a branch of your code and then work against that. This is of course assuming that you are using version control. You are aren't you?
My first thought would be to
copy the entire source code to another IIS website
script the database over to another database (fresh start for new website)
make necessary adjustments to usercontrols and branding
roll out the new site (as Beta)
In Visual Studio, you can create a new project inside the same solution so that you have access to both projects at the same time.
If you're using Version Control... create a branch, and start customizing from there.
what this will do for you is give definitive separation between the two sites... no users have access across sites, all future customizations will be on a per-site basis, etc.
While I really like the idea CaptainTom posted another solution would be to break off the display layer of your application from the rest of the logic and create a new project that implements the new user experience while sharing the rest of the code
i.e. a FillTimeBrokers project and a PartTimeBrokers project with both implementing their logic from a common Brokers project.

URL Rewriting, Temporary Solution, ASP.Net 3.5

We've got a test site hosted only by IP address. We really need to test some functionality that depends on what subdomain someone is using to get to the site. But of course we can't even USE subdomains with an IP only site.
So, one thought I had was that instead of subdomains, we could have the testers open the site with a URL like this: http://192.168.0.1/smith or http://192.168.0.1/jones and I would then redirect them to http://192.168.0.1/default.aspx?site=smith etc...
Our testers are at the client, and asking them to enter in the querystring would be problematic. Plus, I'd really like to get a quick intro into URL Rewriting.
Can anyone give me any idea if what I want to do is possible, and if so, a pointer to some code or explanation or something?
We are using asp.net 3.5 and iis6, I believe.
Thanks for any help!
I wrote up an introduction to URL Rewriting in ASP.NET on my blog, for what its worth. Feel free to post more questions here to clarify any specific issues you have.
this will definitly work in your situation
http://www.urlrewriting.net/149/en/home.html
we have implemented same what you required is, its open source dll and you need to write some rules in web.config, according to your scanario, your rule something like
<add name="index" virtualUrl="^~/(.*)/Default.aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/Default.aspx?site=$1&urw=t" ignoreCase="true"/>
you could possibly change the hosts file on the testing machine to point domains (and subdomains) at that IP, that way you wouldnt have to rely on DNS and could test as if the domains were assigned.
more information here:
http://labnol.blogspot.com/2004/10/tweak-your-windows-hosts-file.html
Using ASP.NET Routing Without
ASP.NET MVC
Using ASP.NET
Routing Independent of MVC
this is part of .Net 3.5 and is the
same mechanism used by MVC
This makes your life easy, due to the fact that everything is held in the HttpContext.CurrentContext.Items[""]
I have adapted this code for a few project where I have an XML configuration file. I then use this file to build the RouteCollection. This code has also been easily extended to handle 301 redirects for SEO.
This method is also loaded once in your AppPool and removes the need to parse xml files and configurations for every call. This so far has been the best solution for me performance wise.
If you need any assistance please let me know. I will gladly lend a hand.
Edit : 13/09/09
I have not run into that problem yet since I usually handle the membership / authentication verification in every page. I usually have a control or method I call on the page to validate/ authorize a user. My clients rarely use the ASP.Net membership, they usually rely on proprietary sub systems which we need to connect to.
I have extended the examples provided in the above links so that I can write one xml routing table which gets loaded when the application starts up or when I force a RouteCollection update.
so far this has proven itself to work pretty well.
this can also allow for a change in routes while the application is running, with no down time.

Categories

Resources