Multiple IIS Application With Same C# MVC Controller - c#

I'm building a site for SaaS.
I'd like to distinguish sites by Domain name to use same contoller.
The reason why I want to make multiple IIS Application is, There are tons of HttpContext.Current.Application in Application_Start() and OnActionExecuting(). And It should be isolated by domains.
My questions are :
Is there any solution for multiple IIS Application using same C# MVC controllers?
If not, Is there other container instead of HttpContext.Current.Application?
Or, Is there other solution that is more elegant, efficient, or effective?
What I tried for creating multiple IIS Application are :
Setting same path.
Set only bin directory to same path as virtual directory
However, Nothing works.
I Hope this is helpful
Windows Server 2012 / IIS 8.5
VS 2013 / C# MVC5 / .Net Framework v4.5.0
Thank you.

Is there any solution for multiple IIS Application using same C# MVC controllers?
Yes.
IIS7 - How do I use the same physical path for different domains?
Can I configure IIS to use the same physical path for different sites but use custom web.config
If not, Is there other container instead of HttpContext.Current.Application?
Or, Is there other solution that is more elegant, efficient, or effective?
It is possible to have multiple domains pointed to a single web application. For more information take a look at IIS Bindings

Related

Deploying ASP.NET Core Web API and ASP.NET Core with Angular in a subfolder (1&1 Windows Business Hosting)

I've acquired a 1&1 Windows Business Hosting which allows to deploy ASP.NET Core applications (so yeah, I have no access to IIS solutions of building as application stuff or that kind of things I've seen in other posts). I wanted to deploy a web and an API in different subfolders within the 1&1 server I've acquired.
What I want to achieve is the following:
Imagine that my domain is https://myDomain. com.
If a user access directly that URL he should see a specific page of the Angular Web App. However, if the called is https://myDomain. com/api/controllerName it should do whatever I have programmed in that controller of the Web API.
I want to have the folder structure something like this:
But it is also valid if I manage to get it like this:
Is any of these two cases even possible to be done? If possible, how I should proceed for being able to do it? I don't have a lot of knowledge in these topics related to web deployment.
What I have managed to do up until now:
If I deploy just the ASP.NET Core Web API outside the subfolder it works with no issues. If I deploy just the ASP.NET Core with Angular outside the subfolder it also works. My issue is that I'm unable to get them both to work at the same time when at least one of them is in a subfolder.
Alternatives on how to achieve this are also welcome!
Thanks in advance :)
You can deploy ASP.NET Core Web API and ASP.NET Core with Angular in two folders as shown in the image below.
These two folders are virtual directories in IIS. If you want to specify which app to access by default, you can modify the rewrite rule in web.config under the wwwroot folder.

How to make IIS website override the root web.config in an Asp.Net MVC website

I have created two websites in IIS, both pointing to the same directory on my local machine. Each site needs to be identical except for the appSettings section of web config however both use the same web.config found in the solution.
Is it possible to get IIS to consume a different version of (or override) the web.config file so that each site can see different values for appSettings?
In the production environment there will be several identical websites that differ only in their configuration but all need to communicate with each other via http requests to various endpoints. I am trying to find a way of locally testing this communication without needing to duplicate everything (since the code should always be identical).
My current approach is to create two websites in IIS and attach to the process of the one I wish to debug (but they currently both have the same config so I can't observe any difference in behaviour between them). Although my question above stands, I would be grateful for advice on how to do this if I am approaching this in the wrong way.

Hosting websites with different portnumbers in ASP.Net IIS server

I have just begin using ASP.Net Web application in Visual Studio. What I want to know is that I have two web pages namely index1.aspx and index2.aspx. I want to host them separately using different port numbers in local host on the iis server. I know site binding is used in these cases but not sure how to go about it.
What is the best way to do this? I want them to run simultaneously and communicate between each other.
In IIS there is something called Virtual directory. You can create two web applications in IIS and make both pointing to same physical location on your system.
You can also update settings of each web application to have different index pages. i.e. web app1 shall use Index1.aspx as index page, and web app 2 shall use Index2.aspx.
Virtual directories are so cool, you can use the same code base for multiple tenants. All we have to create is new web apps or sites in IIS.
So I solved it like this:
I created two projects WebApp1 and WebApp2 in the same Solution.
Right Click on Solution Explorer--> Properties--->Select the radio button with Multiple Startup projects.
Also make sure The Action of atleast one of the projects is set to Start only . The rest can be Start Without Debugging.
To connect IIS to your web application say webapp1:
Reference this video:
https://www.youtube.com/watch?v=IwbKquNBNgQ
Hope this helps anyone who is trying this out.

C# .Net IIS Applications within Application

In my organization, there is a process where in for every new website/application to be added into the IIS, we have to go through a 6 weeks complex process and waiting. Even after the process completes the team will not have access to IIS. We can only deploy the build files using TFS, web deploy etc.
I have initiated the process for my first application/site in the IIS. I wanted to know if there is a way I can avoid future request/process for new application, by making this upcoming application an application of applications :). Something like child applications. But remember I do not have IIS access. I still have access to my application's web config. I also have the freedom to manage URL structures/patterns.
Either by using multiple routes, multiple projects etc. Just thinking loud. My applications will be of type web api, mvc etc
Any crazy ideas? Thanks in advance.
You can have several application roots in IIS, which can be virtual or real directories, under the same site.
Those separate applications will have separate configs and will not inherit each other's settings.
You can access your apps under the same domain, or to be configured to use different domains
http://www.domain.com/app1, http://www.domain.com/app2
They can share the same app pool or be configured to use different.
Since you don't have an access to IIS, I'm not sure how would you configure the app pool or domain, but perhaps Microsoft.Web.Administration namespace will help doing this from code. It contains managed classes to manage all aspects of IIS, including the configuration . It can be used from .Net or from PowerShell.
Creating Sites and Virtual Directories Using System.DirectoryServices
Using IIS Programmatic Administration

Publishing a .NET C# website to an external server

I have just completed my first aspx/c# project using Visual Web Developer Express and consuming some custom controls and external web services. It runs fine on my development machine.
If I now want to test this on a shared hosting account, do I just upload all the files with the current project structure? Will there be any problem uploading the DLLs to a shared Windows hosting account? Anything I should be aware of or changes to be made to the code? Can anyone recommend a cheap and good provider (this is just for testing - no mssql required yet).
Thanks!
Does visual web developer have a "publish website" menu item under the Build menu?
If you want to pre-compile your site and publish it with all dependencies the easiest way I've found. You can then choose to publish it to either an FTP site or the file system. I usually choose the filesystem and then FTP it up myself to make sure I don't overwrite any config files.
If I'm working on a low volume site for a client and performance isn't a problem, I'll just upload my working directory right up to the server so I don't have to deliver the source code separately and I know they won't loose it.
Oh, and one other thing, if you don't configure it special, I would expect you will have to upload your site to the root directory of your hosting account. GoDaddy does have the ability to specify certain directorys as their own ASP.NET application. If you do that you can put your app in a sub-dir of your choosing.
-Al
It would depend on your website provider. You need to get one that supports the .NET runtime. Once you have that, then you simply upload your code and all should work. I personally use www.godaddy.com. You can see an example ASP.NET site hosted by them at www.chessbin.com.
I hope this helps.
Adam
The hosting companies may vary on what they require, but I would think a simple xcopy deploy would be sufficient for most. Here's a link to one that seems to have good prices (disclaimer: I have never used them)
http://www.reliablesite.net/v3/index.asp

Categories