0

I am having a problem to access my application when I put it inside a website in IIS.

The application works if I publish it as a website. As you can see in the screenshot below, the application is a website. I can access it by just typing the Server IP Address in the browser. Scenario that works

However, I need my server to host multiple applications. This server that I am testing is a copy of another server that hosts multiple asp net applications. The difference is that the applications that this other server hosts are not MVC based. Therefore, I have it working for the old application I have.

I have this new project that I've been developing using ASP Net MVC. My guess is that there is a problem with routing althought I've tried all of these suggestions already:

What is need is something like:

http://ServerIPAddress/Application1

http://ServerIPAddress/Application2

The scenario bellow is what I am aiming for:enter image description here

Finally, here is the error I am getting. Weird thing is that the website starts to load some things.enter image description here

UPDATE: I forgot to mention I am using React JS in my application. I found the problem was related to the router.

Arturio
  • 418
  • 1
  • 7
  • 25
  • Possible duplicate of [Running an ASP.NET MVC app from a virtual directory in IIS7](https://stackoverflow.com/questions/6360175/running-an-asp-net-mvc-app-from-a-virtual-directory-in-iis7) – Panagiotis Kanavos Feb 05 '18 at 13:35
  • Do you get any error in the Windows Event Viewer? I think that should give you a proper detailed message. Also, verify the application pool is targeting correct .NET CLR version. There are many possibilities, so your first option should be to get the exact error message. – Nirman Feb 05 '18 at 13:43
  • 1
    you can host multiple _websites_ by making them listen on different port numbers. You can host multiple _applications_ by creating them within Virtual Directories within a single website. Make sure you're using routing correctly and using relative URLs (and not absolute URLs or URLs relative to the site root (instead of the directory root) everywhere within your application – ADyson Feb 05 '18 at 15:18
  • The simplest way to check whether there is a problem with the ASP.NET application vs a web server problem is to remove the ASP.NET application from the folder that IIS points to and replace it with a *single HTML file*. Then try to open the file with the browser. If the file doesn't open, there is an issue with the IIS config. If it does, then there is a problem with the ASP.NET application. In the latter case, the first thing to check is whether the port is open to the database server and any other network services it uses. Then check dependencies and config. Divide and conquer. – NightOwl888 Feb 05 '18 at 18:14

2 Answers2

0

Which folder are you choosing while hosting ? Try selecting project folder which is with .sln file & packages folder.

Akash Kool
  • 52
  • 5
0

Well, I am using react Js here, and after some research I found that this problem would be related to the Router.

In order to solve this problem, here is what I did:

1 - In the app.jsx (react uses this file as a router) file I changed:

<Router history={browserHistory}>

to

<Router history={useBasename(() => browserHistory)({ basename: Package.baseName})}>

2 - I referenced my package.json file:

import Package from '../package.json'

3 - Opened my package.json file and added the property baseName:

"baseName":"/nameOfTheFolderInIIS"

After doing that, I was able to connect to my application. https://localhost:80/nameOfTheFolderInIIS/login

Arturio
  • 418
  • 1
  • 7
  • 25