在Stack Overflow上,我看到一些人提到了MVC期货库
这是什么项目?我该如何使用它?文件在哪里?
我在Visual Studio 2012中使用了新的MVC 4 Internet应用程序模板.我已经为MVC 4 Futures安装了Nuget包.在我的_Layout.cshtml构建导航菜单中.
这可以工作并构建正确的URL:
@ Html.ActionLink("客户","索引","客户")
这就是我想要的工作,一种强类型的变体:
@Html.ActionLink<CustomersController>(c => c.Index(), "Customers", null)
Run Code Online (Sandbox Code Playgroud)
它感到悲伤的是"不能从方法组中选择方法.你的意思是调用方法吗?",但有些东西告诉我这不是真正的问题.
这会编译并输出正确的HTML,但不能内联:
@{
var t = Html.ActionLink<CustomersController>(c => c.Index(), "Customers");
Response.Write(t);
}
Run Code Online (Sandbox Code Playgroud)
如何使用Razor的语法(有或没有Futures)在MVC 4中构建强类型的Action/ActionLink?
如何使用ASP.NET MVC 2 Preview 2 Futures RequireHttps属性?
我想防止将不安全的HTTP请求发送到操作方法.我想自动重定向到HTTPS.
MSDN:
我该如何使用此功能?
伙计们,
到今天为止我应该在我的项目中引入T4MVC还是使用MvcContrib的强类型?
return RedirectToAction(MVC.MyController.MyAction());
Run Code Online (Sandbox Code Playgroud)
要么
return RedirectToAction<MyController>(c => c.MyAction());
Run Code Online (Sandbox Code Playgroud)
努力坚持标准/主流并保持最新.
我知道,这个网站上有问答,我很想知道什么是最新的和最好的,而不是2年前.
提前致谢.
asp.net-mvc asp.net-mvc-futures mvccontrib t4mvc asp.net-mvc-3
我在我的ASP.NET MVC站点中启动并运行Elmah,并且我希望将其界面与站点的管理页面集成.默认情况下,您使用url~/elmah.axd调用接口,该接口在MVC系统外部运行.安装要求你告诉MVC忽略路由,所以没有控制器或任何知道elmah的东西.安装建议特定忽略,即使默认情况下已被忽略:
public class MvcApplication : System.Web.HttpApplication {
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("elmah.axd");
...
}
Run Code Online (Sandbox Code Playgroud)
我想尝试将elmah.axd集成为网站的一个组件.我想有一个Elmah控制器,其视图使用Futures助手Html.RenderRoute,但我不确定要传递的参数:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Elmah</h2>
<% Html.RenderRoute(???); %>
</asp:Content>
Run Code Online (Sandbox Code Playgroud)
这是否有意义 - 有没有办法将网址传递给Html.RenderRoute?有没有更好的方法不使用Html.RenderRoute?
有这个代码,它给了我一个警告: Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
public async Task<ActionResult> Details(Guid id)
{
var calendarEvent = await service.FindByIdAsync(id);
if (calendarEvent == null) return RedirectToAction<CalendarController>(c => c.Index());
var model = new CalendarEventPresentation(calendarEvent);
ViewData.Model = model;
return View();
}
public async Task<RedirectResult> Create(CalendarEventBindingModel binding)
{
var model = service.Create(binding);
await context.SaveChangesAsync();
return this.RedirectToAction<CalendarController>(c => c.Details(model.CalendarEventID));
}
Run Code Online (Sandbox Code Playgroud)
如果我添加await运算符我得到:
Error …
我确定我已经看过这种语法
<%= Url.Action((MyController c) => c.MyMethod("a")) %>
Run Code Online (Sandbox Code Playgroud)
或类似的东西,作为在没有魔术字符串的ASP.net MVC中生成动作URL的方法.但是,我找不到Action过载.我有ASP.NET MVC 1.0.它在哪里?
我们使用ASP.NET MVC Futures项目(Microsoft.Web.Mvc)来使MVC 3应用程序能够使用RESTful路由.此应用程序已在MVC 1及其相关的System.Web.Mvc.Resources.dll程序集下完美地工作,以实现相同的功能.
我们正在注册这些路线:
routes.MapResourceRoute("MyController", "{MyItemId}");
Run Code Online (Sandbox Code Playgroud)
哪个应该给我们的路线,如:
/MyController
/MyController/{MyItemId}
/MyController/{MyItemId}/EditForm
/MyController/CreateForm
Run Code Online (Sandbox Code Playgroud)
我们得到四个有效路由中的三个 - 该列表中的第二个路径(/ MyController/{MyItemId})返回错误:
Server Error in '/' Application.
The RouteData must contain an item named 'action' with a non-empty string value.
Run Code Online (Sandbox Code Playgroud)
当我尝试追加?action = Details或其他向URL注入动作参数的方法时,我得到404错误.看起来Futures代码中的WebEnabledApi属性发生了显着变化 - 其他任何有这些问题的人都有解决方案吗?
我想知道是否有人知道是否可以使用任何"开箱即用"的ASP.NET MVC3助手来生成"链接按钮"......我目前使用以下内容:
<a class="button" title="My Action" href="@Url.Action("MyAction", "MyController", new { id = item.Id })">
<img alt="My Action" src="@Url.Content("~/Content/Images/MyLinkImage.png")" />
</a>
Run Code Online (Sandbox Code Playgroud)
我试图避免使用MvcFutures,但即使我能够使用它们,我也不认为它有一个扩展方法可以实现这一点.(我相信在这种情况下的解决方案是滚动自定义帮助程序,如此处所示)
最后,这篇文章也有一个好主意通过CSS来处理这个问题,但这不是我要问的......
随着MVC2的发布,MVC Futures库的更新中包含哪些值得注意的功能?
我在模型元数据中设置了Display属性的Order 属性值。
[MetadataType(typeof(OccasionMetadata))]
public partial class Occasion
{
private class OccasionMetadata
{
[ScaffoldColumn(false)]
public object Id { get; set; }
[Required]
[Display(Name = "Title", Order = 0)]
public object Designation { get; set; }
[Required]
[DataType(DataType.MultilineText)]
[Display(Order = 3)]
public object Summary { get; set; }
[Required]
[DataType(DataType.DateTime)]
[Display(Order = 1)]
public object Start { get; set; }
[Required]
[DataType(DataType.DateTime)]
[Display(Order = 2)]
public object Finish { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
我使用DisplayForModel和EditorForModel方法在强类型视图中呈现我的模型。
<%= …Run Code Online (Sandbox Code Playgroud) asp.net-mvc annotations metadata asp.net-mvc-futures asp.net-mvc-2
我刚刚使用Package Manager在我的解决方案中安装了MVC 5期货,但我找不到这个帮助方法Html.Serialize,这是之前的MVC Futures版本.
我的问题:我需要包含哪些命名空间来开始在MVC 5期货中使用Html.Serialize帮助方法?
asp.net-mvc ×8
c# ×3
.net ×2
action ×1
annotations ×1
asp.net ×1
asynchronous ×1
elmah ×1
https ×1
lambda ×1
magic-string ×1
metadata ×1
mvccontrib ×1
razor-2 ×1
ssl ×1
t4mvc ×1