问题
I have done, a lot of research on this, I will try my best to explain the detail code bit wise,
I am creating an application using angular js with web api as service, when i run the application i get the # in URL. In order to remove the # from the URL, we need to add the below like in angular config, almost all suggested to add,
$locationProvider.html5Mode(true);
so i have added like this,
angular.module('myapp', ['ui.router'])
.config([......., '$locationProvider',
function (......., $locationProvider) {
$locationProvider.html5Mode(true);
.........
}]);
then i have also added the base tag inside the tag in index(master) file, as shown below,
<base href="/" />
When i was did this much, i get HTTP Error 404.0 - Not Found when i reload/refresh the page, then i did little more R&D, and i have found someone had suggested to add the below code in web.config,
<system.webServer>
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
When i add this i get error when i try to login, i get 405 error as shown below,
But when i remove the code added in web.config then it works fine, but again when i reload i get 404 error.
Is there something to do in web api config, i did some stuff there to but no result, anyone can please help me.
Please do let me know if you need any other details,
Thanks in adv..
来源:https://stackoverflow.com/questions/41788560/remove-from-url-in-angular-js-spa