I have an existing webforms project, and I want to add my new MVC4 (mobile-focussed) site to it, as a subdomain. I also want it to be able to access the session variables from the webforms site. The idea is that the user logs in on the webforms site, sets a session variable and gets redirected to the mobile site (on the subdomain).
Initially I have added my MVC site to the webforms site, by making changes to the web.config, global.asax (for routing etc.), Controllers, Views and other folders at root level. This allows me to access the session variables. However because the webforms site is well-established (old) there are implications to changing the web.config (least of all re-testing). Hence the need for a subdomain.
Is it as easy as dropping my MVC site's folder into the Webforms root, so it has its own web.config, and changing the global.asax to route to it (and then creating a subdomain)? Will I still be able to access the session variables in the subdomain?
You can create a new project for the MVC mobile, configure the domain binding in IIS in something like that m.mydomain.com.
In the web.config of the two you define the same main domain:
<httpCookies domain=".mydomain.com"/>
Here start the difficoult task, you need to play attention to share the same machineKey in the two projects and probably you need to add an HttpModule depending on the selected session scenario.
Take a look on this article that can help you on some guidance.
To share the session, I implemented this from Microsoft. It is a HttpModule.
http://support.microsoft.com/kb/2527105
There was some additional work to do - I felt this article assumes you know a little about IIS. For example I had to manually add the module using IIS Manager.
I managed to get it to work in IIS7 by manually adding the Module using IIS Manager.
(Open IIS Manager -> select the application -> click modules (top right) -> add the SharedSessionModule by clicking 'Add managed module'.
Name: SharedSessionModule
Type: <namespace>.SharedSessionModule
(a dialog box said it could not find the assembly but at runtime it was fine)
Then Restart IIS.
The problem I then had was "session state is not available in this context" when serving up non-page items like images, .pdfs etc. Before I solved this, I have been asked to use my initial method (side-by-side) so I have not found how to change this BUT there are many suggestions on SO and other sites.
Related
I have published my asp.net MVC web application under the “Default web site” inside IIS. I actually added two versions of my web application:-
one directly under the default website and it can be accessed by typing http://servername
one under presaging path , and can be accessed by typing http://servername/prestaging
so I got confused on which approach it is recommend to add my asp.net web application, and what is the difference between adding my web application under the default web site, or creating a whole new web site ?
Thanks
This has more to do with organization within your company's IIS structure than right and wrong. If the site you built truly is the only site on the server, putting it on the Default site is not looked down upon.
But if the application is a sub application of the default site, the latter approach is the more appropriate approach if you only get to access the site from the //servername URL.
If you have a separate domain, myapp.servername.com, you can install it into the default iis site and add a binding or you could create a whole separate web site.
Has more to do with your structure than right or wrong.
Edit
To answer your comment, creating the site under the default web site will make the URL in most cases be: 'http://myservername/MyApp'. Creating your own application would require (in most cases) a separate binding address, 'http://myapp.myservername.com' It is really only affecting the URL you place in your browser and nothing else. More complicated setups are possible, but for most cases, these are your two options.
I have an ASP.NET MVC 3 website which is running on http://localhost/. I also have a new project (ASP.NET MVC3) and I want to deploy it as application
so the url will look like http://localhost/child/
But I have problems with images. If I create image using <img src="/content/img/site-logo.png" alt="logo" />
the image is not available, because the actual URL should be /child/content/img/site-logo.png.
I can solve it if I put url in Url.Content("~/content/img/site-logo.png")
but I don't want to change all my images now.
Is it some more easy solution? Some IIS 7 settings?
I had the same issue, but I found the reason why it was forcing authentication on the Contents folder.
When a user is not logged in yet, they are classified as Anonymous Authentication. In IIS7 (which is what I am using, guessing it is the same in IIS6) you need to open the authentication window in features view. Then edit the Anonymous Authentication, to use your application pool identity, or the default one, just make sure that user has permissions to read in that folder.
That fixed it for me, hope it works for you.
I can solve it if I put url in
Url.Content("~/content/img/site-logo.png") but I don't want to change
all my images now.
I am not aware of any IIS setting, other than of course setting your application to run at the root of the IIS web site.
You should always use url helpers when dealing with urls in an ASP.NET MVC application. So you really should change all hardcoded urls, and by the way this doesn't include only images, it could be also anchor hrefs, form actions, hardcoded urls in your javascript files, ...
You can create virtual directory in root iis project and point it on directory with images. BUT, you should better spend this time to clean up your image paths because it, probably, will bite you in future again.
Our customer has a requirement to extend the functionality of their existing large government project. It is an ASP.NET 3.5 (recently upgraded from 2.0) project.
The existing solution is quite a behemoth that is almost unmaintainable so they have decided that they want to provide the new functionality by hosting it on another website that is shown within the existing website.
As to how this is best to be done I'm not quite sure right now and if there is any security issues preventing it or that need to be considered.
Essentially the user would log on to the existing web site as normal and when cliicking on a certain link the page would load as normal with some kind of frame or control that has within it the contents of the page from the other site. IE. They do not want to simply redirect to the other site they want to show it embedded within the current one such that the existing menus etc are still available.
I believe if information needed to be passed to the embedded page it would be done using query strings as I'm not sure if there is even another way to accomplish this.
Can anyone give me some pointers on where to start at looking to implement this or any potential pitfalls I should be aware of.
Thanks
if the 2 sites are hosted from the same network (low latency between them) you could use state server for session management. that way, when you authenticate on one site, you will also be authenticated on the other, and share user state across them.
its pretty simple, in your web config of each web server you'd point to the state server (which could be located on one of the web servers)
<configuration>
<system.web>
<sessionState mode="StateServer"
stateConnectionString="192.168.1.103:42424"
/>
</system.web>
</configuration>
http://en.csharp-online.net/ASP.NET_State_Management%E2%80%94Storing_Session_State_out_of_Process
create a virtual directory under the primary domain. If your domain is www.mydomain.com then create a virtual directory www.mydomain.com/site and port the new website application under /site virtual directory. This was linking should become very much relavant. With this the virtual-directory application will also retain all domain cookies set by primary domain.
I would suggest to make the second website look exactly like the first one or at least use the same MasterPage, so you can redirect from one site to another without any visual difference.
If your site needs authentication, consider that you would need to do something to prevent the user to log in twice, an option could be to send an encrypted token to the second site.
All of this if you are forced to have a second site, if not just use a virtual directory
You could use something like UFrame. I've used it a couple of times and seems to do quite a good job with it...
"goodness of UpdatePanel and IFRAME combined"
http://www.codeproject.com/KB/aspnet/uframe.aspx
I would use an iFrame to embed that website in within your existing application. Just set the "src" attribute and pass in any query string parameters the other site needs to render correctly.
You can still pass in sensitive data in the query string, however it would make sure to encrypt it before sending it in.
I know it is not the most elegant solution, but it gets the job done. And from the description of the existing app, it doesn't seem like your customer cares for "elegance" :)
Hope this helps
We configured IIS 5 by mappping * to asp.net handler so that ASP.NET MVC works. After configuring this, directory browsing is not working.
Also uploadify jquery plugin is not working. Showing IO error 2038.
Can someone please suggest us how to enable directory browsig with ASP.NET MVC configurations on IIS 5?
I don't think that you'll be able to get directory browsing to work with ASP.NET MVC in the same application. When you added the wildcard mapping, you told ASP to handle every request. If the request doesn't map to an actual file, it will try to match a route in MVC. If there isn't a matching controller with an index (assuming that's your default) action, then it will fail.
My suggestion is to split your web site into "application" and "content". Set up the application as a separate web site and apply the wildcard mapping there. Leave your content with the original configuration. I don't use IIS5 any more -- with one exception on an old XP development box -- I'm afraid that can't really be of more help.
If I were you, though, I'd upgrade to a more recent OS and web server. Expecting new technology to work on a decade-old platform is very optimistic.
I am making this in a proactive attempt to head off any potential problems which could arise from this. The situation is that we are developing an ASP.NET application for a client which will handle the online ordering from their customers. This application is going to be using the same database that their current WinForms application uses (no real issue here).
At the same time we are developing a new front-end website for them using DotNetNuke. The DotNetNuke app will simply be linking to the ASP.NET application for the customers to submit their orders (no need for them to communicate back and forth, etc.)
The plan is to host both applications on the same box at the client location. What I am looking for are potential problems or setup tips which would prevent possible conflict between the two apps (web.config conflicts, etc.) Is there a problem with having both hosted on the same location, how should IIS be set up, etc.?
If there are any external resources also available which could address this, please feel free to link them as well.
Option 1: Make all the apps separate virtual directories off of the root website. Then have the root document redirect you to the proper subdirectory for the default application for that website(DNN).
Option 2: (DotNetNuke in root, other site in subdirectory) There will be many issues with web.config inheritance if the new application is not built with DotNetNuke, but you can get around these by blocking inheritance of the root web.config. Basically you add the following to your root web.config(DNN) file.
<location path="." inheritInChildApplications="false">
<system.web></system.web>
</location>
Option 3: As Scott said, create seperate sites with differnt subdomains and link them together. You can setup a redirect so whatever.com/order sends a user to order.whatever.com.
Just an FYI, if you use
inheritInChildApplications in DNN 4.7-4.9.2 (haven't verified 5.0) you will run into ScriptManager errors, previous versions of DNN don't have the problem.
We host a DNN site for our corporate site on the same Windows 2003 server with a bunch of other sites (.NET 2.0, SugarCRM, and even some WordPress instances with PHP extensions in IIS). These sites are 'separate' websites, and not subwebs of the default site. It's a real melting pot, and it works well. We did create some separate app pools for the PHP, .NET 2.0, and .NET 3.0/5 sites to ensure that they did not foul each other.