I have a .NET Core website which is published successfully and works great under 2 scenarios:
- In debug mode
- When hosted in IIS as a new website.
However, hosting on IIS as a new website leads me to having to specify a new port to be used and access it by it (localhost:5000
).
However i would like to address it as the domain itself like localhost/mywebsite
. From my understanding this could be done by using the default web site, or by creating a new website with port 80 and disabling the Default Web Site. However i cannot disable the Default Web Site.
When i try to add my website to the Default Web Site, i have numerous errors because ultimately, the routing is not good. For example, the main page works (for example localhost/mywebsite
) but when i click on a button to get to the login page, im routed to localhost/login
and not localhost/mywebsite/login
.
Extra information:
Published folder: After publishing, i have 2 folders: wwwroot
, runtimes
. Other than that i have all the config files and binaries.
web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\mywebsite.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration>
Resources are located in project's wwwroot. Resources included are JQuery and images. These also do not work when used as application under Default Web Site
.
example post method requested by first comment:
<form method="post" enctype="multipart/form-data" action="/Login/Login">
<table style="border: none">
<tr>
<td>
Username:
</td>
<td>
<input type="text" name="username" required />
</td>
</tr>
</table>
<input type="submit" value="Log-In" />
</form>