많은 질문을 검색했으며 아무도 내 구체적인 문제를 해결하지 못하는 것 같습니다.Asp.Net 핵심 경로가 제대로 작동하지 않습니다.
자습서를 읽었으며 [Route("Text")]
은 자습서 에서처럼 작동하지 않습니다.
이 코드 그래서 :
public class AboutController
{
public string Copyright() {
return "\u00a9 Copyright are the best";
}
public string Year() {
return "2016";
}
}
나는 아무런 문제 localhost:xxx/about/copyright
및 localhost:xxx/about/year
에 갈 수 있습니다. 그러나 AboutController
선언 직전에 [Route ("what")]을 추가하면 이제 localhost:xxx/what/copyright
또는 localhost:xxx/what/year
으로 이동할 수 없습니다. 나는이 시도하지만 경우 :
[Route("what/[action]")]
public class AboutController
{
[Route("rights")]
public string Copyright() {
return "\u00a9 Copyright are the best";
}
public string Year() {
return "2016";
}
}
내가 localhost:xxx/what/year
에 갈 수 있지만, 그래서 localhost:xxx/what/rights
(또는 그 문제에 대한 localhost:xxx/what/copyright
에, 무엇을 내가 실종되지
네, 맞습니다. 컨트롤러의 경로를'home' 대신'what'으로 바꾸려면 어떻게해야합니까 ('localhost : xxx/home/... '대신'localhost : xxx/what/..')? 튜토리얼에서 나는 그들이 단순히'public 클래스'AboutController' 앞에 Route ("what")을했다고 본다. –
컨트롤러에서'/ [action] 부분을 제거한 다음'Year()'에'[Route ("year")]'를 추가하십시오. 그러면'localhost : xxx/what/year'과'localhost : xxx/what/rights'을 얻을 수 있습니다. –
네, 그게 해결책입니다. 그러나 이것 역시 튜토리얼에서 추가하고 싶습니다. (다른 MVC 버전일까요?) –