- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有时我的应用程序会生成类似 http://localhost/?Area=
的 URL或http://localhost/SomeController?Area=
我目前没有在此项目中定义任何区域,并且我已尝试从应用程序启动中删除区域注册。
我找到的唯一答案是使用 <a href="Url.Action()">
网址。
必须有一种更干净的方法来删除它。手动从 URL 中删除它似乎提供了完全相同的结果,但我不确定为什么会出现这种情况。
如何使用路由系统解决此问题?请注意,我使用 t4mvc 生成操作链接,而不是默认的MVC ActionLink 帮助程序
编辑:
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
/// <summary>
/// Registers MVC Routing Collection.
/// </summary>
/// <param name="routes">The routes.</param>
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"secstdsrte",
"SecondaryStandards/{standardType}/{sampleid}",
MVC.Reports.SecondaryStandards(),
null,
new { standardType = new SecondaryStandardTypeConstraint()
}
);
routes.MapRoute(
"misaRoute",
"Misa",
MVC.Reports.MISA()
);
routes.MapRoute(
"outfallroute",
"Outfalls/{fromDate}/{toDate}",
MVC.Reports.Outfalls( ApplicationController.DefaultFromDate, ApplicationController.DefaultToDate),
null,
new
{
fromDate = new DateTimeConstraint(),
toDate = new DateTimeConstraint()
}
);
routes.MapRoute(
"offspecRoute",
"Offspec/{fromDate}/{toDate}",
MVC.Reports.OleOffspec(ApplicationController.DefaultFromDate, ApplicationController.DefaultToDate),
null,
new //route constraints
{
fromDate = new DateTimeConstraint(),
toDate = new DateTimeConstraint()
}
);
routes.MapRoute(
"searchRoute",
"Search",
MVC.Reports.Search()
);
routes.MapRoute(
"compareresultsroute",
"compare/{samplePoint}/{analysis}/{fromDate}/{toDate}",
MVC.Reports.CompareResults(null, null, null, ApplicationController.DefaultFromDate, ApplicationController.DefaultToDate),
null,
new
{
samplePoint = new SamplePointExistsConstraint(),
analysis = new AnalysisExistsConstraint(),
fromDate = new DateTimeConstraint(),
toDate = new DateTimeConstraint()
}
);
routes.MapRoute(
"reportsRoute",
"Reports/{samplePoint}/{fromDate}/{toDate}",
MVC.Reports.Results("", ApplicationController.DefaultFromDate, ApplicationController.DefaultToDate),
null,
new //route constraints
{
samplePoint = new SamplePointExistsConstraint(),
fromDate = new DateTimeConstraint(),
toDate = new DateTimeConstraint() }
);
routes.MapRoute(
"railcarsRoute",
"RailCars/{forDate}",
MVC.Reports.RailCars(ApplicationController.DefaultToDate),
null,
new { forDate = new DateTimeConstraint() }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new
{ controller = "Reports", action = "Index", id =UrlParameter.Optional } // Parameter defaults
);
}
/// <summary>
/// Returns boolean value indicating whether the application is currently in debug mode
/// </summary>
public static bool isDebugging
{
get
{
return HttpContext.Current != null && HttpContext.Current.IsDebuggingEnabled;
}
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
}
最佳答案
此问题之前已在 T4MVC @Url.Action(MVC.Controller.Action()) Renders "?Area=" Parameter in QueryString 上讨论过.
简而言之,当站点不使用区域时,这是 T4MVC 中的一个错误。您可以通过删除此行(第 303 行附近)来解决此问题:
result.RouteValueDictionary.Add("Area", area ?? "");
关于asp.net - 如何防止 ?Area= 添加到生成的 URL 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9522895/
你好,我有一个关于 d3 的性质的问题,我认为这是关于 d3 的非常深入的细节。 据我了解, d3 中的变量声明,如 var svg = d3.select('boby').append('svg'
如 this question 中所述,java.awt.geom.Area的equals方法定义为 public boolean equals(Area other) 而不是覆盖 Object 中的
我希望红色区域始终适合内容,以便下方区域(评论部分)始终紧随其后而不是下方。 在 chrome 中,它有效,但在 Firefox 中无效(见图片)。 我认为通过添加 grid-template-row
我想在曲线下填充一小块区域。但是,带状几何图形将分布的两个“部分”连接起来。 library(tidyverse) density(rnorm(1000, 0, 1)) %$% data.fram
我在 chrome 中得到一个奇怪的行为,它在空白 IE 之后创建正方形 Price: 123234 但这毕竟不是网站上的所有空格,只是在我得到两个字符串如 Price: 然后在我的代码中添加价格的情
我有一个小问题,我不认为我想做的事情可以只用纯 CSS 来实现,但我想我还是要问。 基本上,我有一个 DIV,其中包含一个超链接元素,该元素的大小小于其父 DIV。所以实际上我在一个正方形中有一个正方
我正在尝试将元素放置到一个简单的 9x9 网格中,但是当我尝试将元素放置在左下角或右下角时,它们并没有停留在那里,而是在它们应该放置的位置上方的一个方框内结束。 Here's a JSFiddle s
我一直在阅读 CSS Grid tutorial在 CSS Tricks 中,但一个基本方面让我有点困惑。 似乎有两种方法可以决定一个网格元素跨越多少个单元格: grid-template-area使
我试图实现这个 great blog Gavin Simpson 使用从 cancensus 包下载的数据发布,但在尝试评估 gam 时出现以下错误: Error in smooth.construc
基本上,每当我发送文本区域消息来填写电子邮件正文时,该文本区域的名称总是会继续。因此,例如,如果我在文本区域中输入“Hello World”,然后按发送,我的电子邮件应用程序将打开,正文显示:“mes
PyTorch 函数 torch.nn.functional.interpolate包含多种上采样模式,例如:nearest , linear , bilinear , bicubic , trili
我正在尝试使用 jQuery 根据另一个区域的高度扩展一个区域。但是,第一个区域是动态内容,所以我不能像在 JS 代码中那样设置固定值(第 6 行,高度为 175px)。 我这里有一个例子:https
我在 MATLAB 中创建一个图形,然后对图形的背景进行着色以突出显示区域。这方面的一个例子如下: clc; clear all; hFig = figure; y = [0:0.1:2*pi]; x
我读了很多关于这个问题的资料,但我想不通。 路由和 ASP .NET MVC 的一切都非常简单,但我仍然坚持这一点。 问题是我正在尝试使用这种形式对给定的 url 进行 GET: {区域}/{ Con
题目地址: https://leetcode.com/problems/rectangle-area/description/ 题目描述: Find the total area covered
我在ScrollViewer中有一个Canvas。 Canvas 的尺寸为600x600,而ScrollViewer 400x400。如果我滚动到右侧,则看不到Canvas左侧的200pxl。因此,我
考虑一个圆。现在考虑从圆心向右绘制的圆半径。现在想象半径绕圆心旋转,旋转时扫过一个区域。我的问题是:当半径从 0 度旋转到围绕圆的任何选定的度数时,我想使用 iPhone 的动画技术用与圆的背景区域不
我想知道是否有人知道为什么 IB 在奇怪的 Nib 上到处都有莫名其妙的高亮区域.. 下面是一个例子: 我的意思是我用红色标记的区域内的亮区... 分割 View 下方没有 View ,没有与之对应的
我是 IOS 应用程序开发的新手,目前正在学习 Auto Layout。 有时,当我添加约束时,“安全区域”会丢失。 我正在尝试为我的 StackView 添加约束,其中 0、0、0、0 用于相对于“
我添加了 UIButton类型为 UIButtonTypeInfoDark到一个 View 和它的触摸区域是巨大的。我知道 Apple 推荐 44px,但在这种情况下,它要大一些。我为 View 设置
我是一名优秀的程序员,十分优秀!