- MVC中的Helpers中是啥?
Helper是mvc2中的一个东西,帮助你渲染视图中的HTML控件。如果在面试中你想展示HTML输入框,下面是HTML helper代码。
<%= Html.TextBox(“LastName”) %>
checkbox的代码如下。用这种方式我们可以创建现存的所有HTML控件。
<%= Html.CheckBox(“Married”) %> - MVC的路由选择是什么?
路由选择功能帮你定义一个URL规则,映射URL到控制器。
举一个例子,我们想让用户输入“ http://localhost/View/ViewCustomer/ ”时,它转向到“Customer”控制器并且调用 DisplayCustomer 。这个通过Maproute方法来定义。代码如下:
routes.MapRoute(
“View”, // Route name
“View/ViewCustomer/{id}”, // URL with parameters
new { controller = “Customer”, action = “DisplayCustomer”,
id = UrlParameter.Optional }); // Parameter defaults - 在哪里写路由映射表
在 “ global.asax ” 文件。
3月7日面试题总结
最新推荐文章于 2022-03-24 21:40:13 发布