In my razor code I have hardcoded links as below:
<a href="/coupling/10" title="Coupling">10</a></li>
I have many links like this and they all show as "Path C:\Code .... not found".
Is there some way I can suppress these errors? I am getting them in Visual Studio 2010 when editing. They are not runtime or compile time errors - just advice to me. Perhaps they are coming from ReSharper but I think I also got them before I installed resharper.
They don't开发者_如何学JAVA stop my code from working as they are routes and not actual links to file. I wonder if there is another way I can write these without using the HTML helpers.
In my razor code I have hardcoded links as below
That's bad. You should never be hardcoding any url in ASP.NET MVC. This is fragile and it might break any time you change your routes or deploy your application inside a virtual directory in IIS. So instead of hardcoding do things properly:
@Html.ActionLink(
"10", // linkText
"coupling", // actionName
"somecontroller", // controllerName
new { id = "10" }, // routeValues
new { title = "Coupling" } // htmlAttributes
)
This way not only that you will no longer get any warning messages but you will have correct and working code.
As far as the warning you are getting, it is due to Visual Studio designer not able to resolve the /coupling/10
at design time.
精彩评论