2014-1219

用如下方法获取UserId报空引用异常

public class BaseController : Controller
{
    protected SiteContext db = new SiteContext();
    protected Guid userId;
    public BaseController()
    {
        userId = Guid.Parse(User.Identity.GetUserId());
    }
}

由于Controller未初始化完成,User为空,重写初始化方法,在初始化(ba 阅读全文>>

标签: MVC5 Controller User Null 阅读:15527
2014-1202

做ASP.NET MVC开发的时候,经常会出现一下错误:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specifie 阅读全文>>

标签: SQL Network Interfaces, error: 26 阅读:10830
2014-1202

使用如下代码加载css:

<link href="/Content/css/home?v=zhVOIpUNuvCOZhJyBcQWpMlozayor4te6k-pM29wHqI1" rel="stylesheet"/>


报403 - 禁止访问: 访问被拒绝。
您无权使用所提供的凭据查看此目录或页面。


解决方法:

如上链接MVC Bundle的处理规则是:

如果服务器存在/Content/css目录,则按照常规文件请求文件系 阅读全文>>

标签: ASP.NET MVC BundleStyle BundleScript 403错误 阅读:10988