我有一个 MVC Web 应用程序,它继承并是 Webform 框架的一部分。webform 框架的一部分输出几个 ASHX 处理程序。其中,我无法删除 with routes.clear(),因为这会将它们全部删除。我仍然需要使用它们。
这是我的问题出现的地方,我有,<link href="@Url.Action("Index", "Styles")" rel="stylesheet" type="text/css" />这指向一个生成动态 CSS 样式属性的控制器。
当页面呈现这样的Url.Action外观时 -
<link href="/MyLayout/Handlers/LoginStyleHandler.ashx?
action=Index&controller=Styles" rel="stylesheet" type="text/css">
Run Code Online (Sandbox Code Playgroud)
至于试图忽略这条路线,这是我尝试过的。这些都不起作用。是什么赋予了?我该怎么做才能将 ASHX 路径排除在我的Url.ActionHTML 帮助程序之外。
routes.IgnoreRoute("{Handlers}.ashx");
routes.IgnoreRoute("{Handlers}/{resource}.ashx/{*pathInfo}");
routes.IgnoreRoute("TMW_LayoutPrototype/Handlers/LoginStyleHandler.ashx");
routes.IgnoreRoute("{*allaspx}", new { allaspx = @".*\.aspx(/.*)?" });
routes.IgnoreRoute("Handlers/LoginStyleHandler.ashx");
routes.IgnoreRoute("{*allashx}", new { allashx = @".*\.ashx(/.*)?" });
Run Code Online (Sandbox Code Playgroud)
使用http://regexpal.com/ 上的 Regex 测试器让我知道我的 Regex 模式@".*\.ashx(/.*)?"是有效的。但是,它不会从 Web 应用程序的 MVC 端删除处理程序。
我的问题的根源源于应用程序的 Web 表单方面。低调地看,在框架内部,MVC 应用程序继承了一个路由引擎。因此,我在 MVC 中的路由位于堆栈底部,而 Webform 路由位于顶部。
忽略路由不起作用,因为路由是在 …
我有一个单元测试课,我在工厂做一些测试.在这个单元测试中,我模拟了一些数据.在模拟数据中,我在NumberModel中有NumberModel(父模型),我有一个名为ReferenceModel的嵌套模型列表.我已经在同一行中为它们添加值时实例化了许多列表,但是当我尝试用我的嵌套模型列表执行此操作时,我发现我不能.
这是单元测试类的片段,我在这里模拟我的数据.
_numberModel = new NumberModel()
{
value1 = 1,
value2 = x,
referenceList = new List<ReferenceModel> { ID = 55, NumberType = Mean } < -- These show undefined
};
Run Code Online (Sandbox Code Playgroud)
我在这做错了什么?我是否需要深入查看父模型中的嵌套列表,以便定义嵌套的模型列表?
我已经构建了一个用于访问WEB API服务的java例程,但是我正在为ASP.Net的VB等价物而苦苦挣扎.我得到API响应,但我不知道如何将其转换为json元素.
java版本是:
public boolean canLogin(){
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(hostURL + TOKEN_ACCESS_URL);
httppost.addHeader("Accept", "application/json");
// Add the post content
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(3);
nameValuePairs.add(new BasicNameValuePair("grant_type", "password"));
nameValuePairs.add(new BasicNameValuePair("username", accessUserName));
nameValuePairs.add(new BasicNameValuePair("password", accessPassword));
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
} catch (UnsupportedEncodingException e1) {
mobileLogDataHandler.ToLog(LogType.Error, "UnsupportedEncodingException closing data stream with error: " + e1.getLocalizedMessage() + ",detail:" + e1.getMessage() + " in canLogin", mResolver, RemoteDataHandler.class);
return false;
}
// post the server
InputStream inputStream = null;
String …Run Code Online (Sandbox Code Playgroud)