I have 1 secure MVC website already hosted at say https://mysite.co.uk. This website has areas, controllers and actions as per normal:
https://mysite.co.uk/kitchen/create
https://mysite.co.uk/bathroom/edit
etc
Initially, I was told that my second MVC website would be able to be hosted under a new url: https://mysite-newsite.co.uk, so I have a new solution with.
But now unfortunately the deployment team have said it needs to be deployed under the initial main url:
https://mysite.co.uk/newsite
We are using iis7 and I have tried to achieve this using Add Application , but I just run into lots of problems with routing, nhibernate dll conflicts etc.
Can this be actually be resolved somehow in iis7 please? Or will the second MVC solution need to be re-written somehow?
Thanks
I think your best bet would be to create a sub-directory in the first application's deployed directory and put the second application there.
You can then set the sub-directory to be its own application in IIS and they will operate independently.
So, you will have url's like this:
https://mysite.co.uk/kitchen/create <-- first site
https://mysite.co.uk/[subdirectory]/controller/action <-- second site
The route urls in the second application should work, but you will need to check this.
Otherwise, you will have to merge the two applications into one solution.
Related
Good morning,
I have a fairly large MVC project with 30/40 controller and a lot of views, i am trying to publish on IIS using multiple application so i can split various sites per different customer.
I want to use my landing page as the base url:
https://somewebsite
I then want to host multiple applications (e.g the same project with different config) as separate applications but under the same main host name.
https://somewebsite/Customer1
https://somewebsite/Customer2
Now i can get my multiple websites fine under the seperate host as application, but when i add my landing page (as the full application) its corrupting the other two sites.
My thoughts are that the routing in the route app (the one i want just for landing page is causing the issue).
Any ideas?
If you are deploying via WebDeploy it will delete subfolders under the host site if they are not part of the host application. You can disable this behavior however with a MSBuild argument:
/p:SkipExtraFilesOnServer=true
OR during the MSDeploy deployment using the following argument:
-enableRule:DoNotDelete
http://www.dotnetcatch.com/2016/02/01/webdeploymsdeploy-quick-tip-keep-existing-files-during-deployment/
The issue lay within the web.config of the applications. The config was being inherited from the master site and causing issues across the board.
Set the clear attributes in the child application config and all is well with the applications.
We have a public website that is already exposed to the outside, although in reality there's really nothing there. Simply default.htm file with "Coming Soon" text in it. (http://vensuresoftware.com/)
We also have a WebAPI we've put together that we want to add to this website. When I publish locally to my IIS6, it works no problem. It's accessed as http://localhost/HRConnect/api/Claims just fine. I've used PostMan, a C# client, and Javascript AJAX to access this just fine. I can also load it in a browser at that URL, and I get the appropriate default controller and action.
However, I have been totally unable to accomplish this same thing on the website. Ideally I'd like to include it as a Virtual Directory to the http://vensuresoftware.com and access it as http://vensuresoftware.com/HRConnect/api/Claims but I've had zero luck doing so.
I have tried to add it as a Virtual Directory as well as an Application under that specific website, but when I access the URL, all I get is "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
I've ensure the Application pool is correct, with an appropriate user and the pass through connection test succeeds. But I just cannot access the service or the URL.
Any ideas or suggestions at all on what I can try? I'm not sure what else I can include here. Nothing special in IIS, nothing special in the service really. There's only 3 actions in it. As I said, it all works beautifully locally, under localhost though.
IIS 7 doesn't have built-in support for extensionless URLs which causes a lot of headaches trying to get MVC and Web API apps to run. I've gotten it to work using both these options. Pick the one that applies to you.
Install this IIS patch which allows IIS 7 to handle extensionless URLs.
If the patch isn't an option because you're worried about breaking other sites on the server, you can make the Web.config adjustment found in this answer. You'll have to do this for every MVC/Web API app you have running on the server.
I have to deal with a legacy asp.net mvc web app (.net 4). It uses some customized routing, which works fine when I use visual studio 2010's development server. However, when I use iis instead (during debugging) it does not seem to work (never used iis during debugging before).
The answer provided here does not seem to help. I already use:
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
Is there any other reason why the routing may not work? Thanks!
A generic post, unfortunately Internet Information System can create a slew of configuration issues. This is quite possibly it's largest pitfall. Is when you launch it on a Deployment Server, Local Server, or a Production Server the outcome may never appear to be the same.
I'll use Internet Information System Six, because it is similar to Seven and Eight but it just lacks certain features.
Inside of your project for ASP.NET MVC Web Application you'll want to right-click your project and select Properties.
You should see a tab that indicates the word: *Web**
Inside this tab towards the bottom you'll want to ensure that Use IIS Web Server is selected.
You'll want to put a Project URL in there.
This field should look like: *http://localhost/ApplicationName*. What your essentially doing here is mapping your project directory for IIS. You see each IIS Site stores a site inside the:
C:\inetpub\wwwroot
That is your Root Site Folder, where IIS will reference all of your Site Components. ** Keep in mind this Virtual Directory in projects is actually different then your IIS Configuration item listed. **
Now you'll want to open Internet Information System, you'll want to setup your File Extensions. So before doing anything in IIS, you'll want to configure your ASP.NET MVC Installer. You need to configure your mappings (ISAPI) to the .mvc extension to aspnet_isapi.dll. This step is required in order for IIS to hand off Routing Request using the .mvc extension to ASP.NET.
From a good blog post he stated:
If you’re planning to use extension-less URLs, you can skip this
section, but it may be useful to read anyways as it has some
information you’ll need to know when setting up extension-less URLs.
Mapping .mvc to ASP.NET
If you plan to use the .mvc URL extension, and are going to deploy to
IIS 6 on a machine that does not have ASP.NET MVC installed, you’ll
need to create this mapping by performing the following steps.
One nice benefit of using the .aspx extension instead of .mvc is that
you don’t have to worry about mapping the .aspx extension. It should
already be mapped assuming you have ASP.NET installed properly on the
machine.
For the rest of you, start by right clicking on the Virtual
Application node (IIS6DemoWeb in this case) and select Properties. You
should see the following dialog.
Make sure your in the Virtual Directory Tab and select Configuration. This will allow changes to the root website. This should bring up your Application Configuration Dialog. That will allow you to physically map your application. Since your using .mvc that is what you'll select.
If .mvc isn't found in the list, you can point to the Data Link Library here:
c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll
Now before you run the application you need to update the default routes, that way they look for the proper file extension. In your Global.asax.cs you'll want to ensure your using .mvc extension.
You would implement a method such as:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}.mvc/{action}/{id}",
new { action = "Index", id = "" }
);
routes.MapRoute(
"Root",
"",
new { controller = "Home", action = "Index", id = "" }
);
}
That should allow the site to properly display. This is a very, very generic and broad example. But hopefully this points you in a good direction.
Update:
When utilizing Internet Information System Seven you have to be aware of the following:
Site Configuration
Application Pool
Database Configuration
Those three items are common culprits to incorrect configuration.
A really wonderful blog can be found here:
Another nice article can be found here:
However, this article should hit the nail directly on the head for you:
As I stated the above detail should resolve your issue. But, with the introduction of IIS 7 they have two completely different methods to allow request: Integrated and Classic.
The major difference is Integrated will perform better and includes more features. Where Classic is designed for backwards compatibility. Your route request processing method is determined by your Application Pool. With this incorrectly configured; it won't work.
Launch the Internet Information Services Manager
In the Connections window, select an application
In the Actions window, click the Basic Settings link to open the Edit Application dialog box
Take note of the Application pool selected.
By default, IIS is configured to support two application pools:
DefaultAppPool and Classic .NET AppPool. If DefaultAppPool is
selected, then your application is running in integrated request
processing mode. If Classic .NET AppPool is selected, your application
is running in classic request processing mode.
From within that box you'll be able to modify the processing mode within an "Edit Application Dialog Box".
Hopefully this additional information better assist you for your goal. The first two blogs are a avoiding IIS, where the third one focuses specifically on IIS 7. If you have any questions let me know.
I've created HttpModule in ASP.NET, and configured it successfully.
My problem is, the module is called only when I give the URL extension (i.e. aspx), if i dont put any extension, the module won't be called.
How can I solve this?
thanks
The problem is that the request is not being handled by ASP.Net - IIS 6 and below only invokes ASP.Net when it encounters a filename that it associates with ASP.Net, such as an .aspx or .axd file extension.
This is similar to the problem faced when attempting to deploy MVC applications to IIS 6 or below (IIS fails to route the requests to ASP.Net), and the solutons are also similar - you can either individually map every extension you wish to see handled to aspnet_isapi.dll the ASP.Net handler (which still won't work for URLs that don't have extensions), or you need to use a wildcard mapping to tell IIS to direct all requests to ASP.Net - note that this will include images and other static files which might get handled less efficiently than normal.
The article Deploying ASP.NET MVC to IIS 6 discusses the solutions for deploying MVC applications to IIS 6 - this discusses potential solutions with greater detail than I have space for here.
I'm trying to make an application that can host multiple ecommerce front ends, so I need to figure out how to route all requests to one class which then parses templates and handles all output.
So my question is then how do I route all requests to one class?
In PHP I would use mod_rewrite and have all requests go to index.php and add "main = new MainClass();", but I have no idea on how to achieve this with ASP.NET
The MVC framework isn't what I'm looking for, since I will host several domains with one system.
It sounds like what you want is an HttpModule. (Sorry for the Google link, but there's a lot about this out there and I'm not sure which is the best resource for you.)
Essentially, what an HttpModule does is intercept requests between the web server (IIS) and the application (ASP.NET).
You can use the Route class to register route handlers for all of the routes you define. Basically, you would create one instance of an implementation of IRouteHandler (or different instances of the same type) for all the permutations of the urls on your site.
Also, it should be said that following statement that you made is misguided:
The MVC framework isn't what I'm
looking for, since I will host several
domains with one system.
Any problems or limitations you would run into hosting several domains in one system with MVC will be apparent in ASP.NET as well; MVC sits on top of ASP.NET, not separate from it.