小编Ami*_*ari的帖子

Asp.net MVC Routing Issue 403.14

one of my controller could not load "Index".for example :

 http://localhost:51638/Reserve/
Run Code Online (Sandbox Code Playgroud)

doesn't work.but http://localhost:51638/Reserve/Index works. and this problem is just for one of my controller and other is correct. and my RouteConfig is:

public static void RegisterRoutes(RouteCollection routes)
        {


            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            // BotDetect requests must not be routed
            routes.IgnoreRoute("{*botdetect}",
              new { botdetect = @"(.*)BotDetectCaptcha\.ashx" });
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "UserHome", action = "Index", id = UrlParameter.Optional }
            );
        }
Run Code Online (Sandbox Code Playgroud)

after delete the controller and add …

c# asp.net-mvc asp.net-mvc-routing razor

5
推荐指数
1
解决办法
907
查看次数

使用 terraform 转义字符串中的特殊字符

您能帮我使用 terraform 实现以下场景吗?我需要在字符串值中的每个特殊字符前加上 // 前缀。

示例:mysplchr="test O'riel*abc"这必须更改为"test O//'riel//*abc"

谢谢

terraform terraform-provider-azure terraform-provider-aws terraform-provider-gcp terraform0.12+

4
推荐指数
1
解决办法
1万
查看次数

如何使用显式转换运算符将一个列表转换为另一个列表而不使用扩展方法?

我将此转换运算符添加到我的类中并且运行良好。当我传递一个类的对象时A,它会将其转换为类的对象B

public static explicit operator B(A a)
{
    //Convert A to B
}
Run Code Online (Sandbox Code Playgroud)

但是当我想将 a 转换List<A>为 a时List<B>,它不起作用。我尝试了以下代码,但它也不起作用。

public static explicit operator List<B>(List<A> a)
{
    //Convert List<A> to List<B>
}
Run Code Online (Sandbox Code Playgroud)

相反,它会抛出以下编译器错误:

用户定义的转换必须与封闭类型相互转换。

我不想使用扩展方法来转换它。

c# conversion-operator explicit-conversion

3
推荐指数
1
解决办法
5794
查看次数

Aps.net core Razor 页面 [FromBody] Ajax post Model 始终为 null

在 Asp.Net core 中,我有一个 razor 页面,我想将 Ajax 帖子发送到 Post 方法,但我总是得到 null 模型。这是我的简化问题。

public class IndexModel : PageModel
{
    public void OnPost([FromBody]A A)
    {
        if (ModelState.IsValid)
        {

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的模型:

[JsonObject(MemberSerialization.OptOut)]
public class A
{
    [JsonProperty]
    public string Id { get; set; }
    [JsonProperty]
    public string CityId { get; set; }
    [JsonProperty]
    public string Infected { get; set; }
    [JsonProperty]
    public string Susceptible { get; set; }
    [JsonProperty]
    public string Recovered { get; set; }
    [JsonProperty]
    public string CityName { …
Run Code Online (Sandbox Code Playgroud)

ajax json asp.net-core razor-pages

1
推荐指数
1
解决办法
2340
查看次数