我认为标题几乎总结了:
ASP.NET MVC RouteLink()
和ActionLink()
ASP.NET MVC有什么区别?
即你何时使用Html.RouteLink()
,何时Html.ActionLink()
在你的视图中使用?
显示此内容的语法是什么?我的程序将始终在我正在创建的分页助手中呈现«并且自从切换到MVC3后,似乎没有办法甚至用Eval(string.FromCharCode)破解它
我开发了 Angular 8 应用程序,我正在使用 routerLink 来导航组件,这些组件工作正常,没有任何问题,但是当我直接在浏览器中输入相同的 URL 时,它没有显示任何内容,并且在控制台中,我看到了错误如下
例如,我打开主页http://localhost:4200/home并在此处添加了 routerLink 以转到http://localhost:4200/about并且我将能够成功查看但如果我输入 URL http ://localhost:4200/about直接在 ULR 里什么都没有显示
我已经处理了 app-routing.model.ts
const routes: Routes =
[
{ path: 'home', component: HomeComponent },
{ path: 'about', component: AboutComponent },
{ path: '**', redirectTo: '/home', pathMatch: 'full' }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
Run Code Online (Sandbox Code Playgroud)
我有 header.component.ts 来处理导航栏,所以我
<router-outlet></router-outlet>
在 header.component.html 中添加了<app-header></app-header>
,然后在app.component.ts 中包含了 header.component.ts 的选择器,然后在最后的index.js 中包含了 header.component.ts 的选择器
。 html 我已经包含了 app.component.ts 的选择器,即<app-root></app-root>
你能告诉我是否有问题。
在问这个问题之前,我已经经历了下面的一切,没有任何帮助
这是复制问题的程序。
将以下行添加到 RegisterRoutes() 方法中的“默认”路由之前
routes.MapRoute(
name: "Test",
url: "Test/{action}",
defaults: new { controller = "Test", action = "Index" }
);
Run Code Online (Sandbox Code Playgroud)将以下内容添加到 Index.cshtml 和 About.cshtml
@Html.RouteLink("link to TestController", "Test")
Run Code Online (Sandbox Code Playgroud)如您所见,生成的 html 代码对于 2 个页面是不同的。我希望 URL 是“/Test”,它为 Index.cshtml 正确呈现,但它成为 About.cshtml 的“/Test/About”。
我的问题是是否有任何记录的方法来生成相同的正确 URL。上面的例子只是为了演示目的而创建的。我想使用路由表信息来生成菜单。
我如何使用这个创建链接 - http://msdn.microsoft.com/en-us/library/dd505243.aspx html.RouteLink使用标题中的html标签?结果我会看到这样的事情:
<a class="" href="#"><div class="someclass">1</div><div class="someotherclass"></div></a>
Run Code Online (Sandbox Code Playgroud)