小编Jac*_*ack的帖子

为什么.Net 4.0中的新Tuple类型是引用类型(类)而不是值类型(struct)

有谁知道答案和/或有关于它的意见?

由于元组通常不会很大,我认为使用结构比使用类更有意义.怎么说你?

performance struct class .net-4.0

87
推荐指数
3
解决办法
2万
查看次数

ASP.Net MVC:如何在 ASP.NET Core 中通过中间件重写 url

在 asp.net 4.0 中,我们可以使用 http 模块来重写模块,如下所示:

protected void Application_BeginRequest(Object sender, EventArgs e)
{
    string CountryCodeInUrl = "", redirectUrl="";
    var countryCode = CookieSettings.ReadCookie();
    if (countryCode=="")
    {
        countryCode = "gb";
    }

    if (HttpContext.Current.Request.RawUrl.Length >= 2)
    {
        CountryCodeInUrl = HttpContext.Current.Request.RawUrl.Substring(1, 2);
    }

    if (countryCode != CountryCodeInUrl)
    {
        if (HttpContext.Current.Request.RawUrl.Length >= 2)
        {
            if (HttpContext.Current.Request.RawUrl.Substring(1, 2) != "")
            {
                countryCode = HttpContext.Current.Request.RawUrl.Substring(1, 2);
            }
        }
        if(!System.Web.HttpContext.Current.Request.RawUrl.Contains(countryCode))
        {
            redirectUrl = string.Format("/{0}{1}", countryCode, System.Web.HttpContext.Current.Request.RawUrl);
        }
        else
        {
            redirectUrl = System.Web.HttpContext.Current.Request.RawUrl;
        }
        CookieSettings.SaveCookie(countryCode);
        System.Web.HttpContext.Current.Response.RedirectPermanent(redirectUrl);
    }   
}
Run Code Online (Sandbox Code Playgroud)

如何使用 …

c# httpmodule asp.net-core-mvc

7
推荐指数
2
解决办法
7628
查看次数

HTTP 413 - 请求实体太大备忘单

我正在尝试将大文件上传到我的 ASP.net core/ASP.net mvc 站点,但不断遇到 HTTP 413 - 请求实体太大。即使当我尝试更新 web.config 时,其他事情仍然会出现问题。有人有处理这个问题的备忘单吗?

iis asp.net-mvc .net-core

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

同时访问 C# List<T> 的多个索引是否安全?

我有一个充满结构的列表,我想同时遍历和更改这些结构。

代码概念如下:

Parallel.For(0, pointsList.Count(), i=> pointsList[i] = DoThing(pointsList[i]));
Run Code Online (Sandbox Code Playgroud)

我既没有添加到列表中也没有从列表中删除,只是访问和改变它的项目。

我想这很好,但我想我应该检查一下:这是否可以,或者我是否需要在某处使用 Lock 以免我弄乱了列表对象??

c# multithreading list

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

“where 子句”中的未知列“Extent1.Discriminator”

我正在使用 Visual Studio 2013 Web 表单应用程序和 MySql 数据库来构建 Web 表单应用程序,但我无法通过“成员资格和角色管理”。我对会员资格使用了数据库优先方法,当我尝试注册新用户时,收到以下错误消息:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: MySql.Data.MySqlClient.MySqlException: Unknown column   'Extent1.Discriminator' in 'where clause'

Source Error: 


Line 16:             var manager = new UserManager();
Line 17:             var user = new ApplicationUser() { UserName = UserName.Text };
Line 18:             IdentityResult result = manager.Create(user, Password.Text);
Line 19: …
Run Code Online (Sandbox Code Playgroud)

mysql asp.net membership-provider entity-framework-6 asp.net-identity

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