I create a controller,contain a method Index.
When I go to website , click the button of this controller.
Why my URL will extra some Character.
when I delete the extra Character, it can Successful operation,
but I don't know how to solve this problem.
I have check _Layout.cshtml . But i didn't find anything woring. When I click the Link of GatewaySettingDevices. The URL will go to http://localhost:10007/%20GatewaySettingDevices What is the %20?
This is my _Layout.cshtml code
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="GatewaySettingClouds" asp-action="Index">GatewaySettingClouds</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller=" GatewaySettingDevices" asp-action="Index"> GatewaySettingDevices</a>
</li>
What is the %20
Answer:
Its a white space before " GatewaySettingDevices"
controller name
. You have to remove that.
From your code it seems that everything is fine, but the reason for adding extra character on your request is asp-controller=" GatewaySettingDevices"
You could see there is a white sprace
before " GatewaySettingDevices"
Just get rid of the white space and it should look like below:
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="GatewaySettingClouds" asp-action="Index">GatewaySettingClouds</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="GatewaySettingDevices" asp-action="Index"> GatewaySettingDevices</a>
</li>
Hope it would resolve your problem. Let me know if the problem still persists