草庐IT

AUTH_USER_MODEL

全部标签

c# - 如何通过 ConfigurationManager 写入 User.Config 文件?

我正在尝试使用ConfigurationManager将用户设置保存到配置文件中。我只想将这些设置限定为用户,因为在没有管理员权限的情况下无法在Vista/Win7上保存应用程序更改。这似乎让我得到了用户的配置,它似乎保存在Win7中([Drive]:\Users\[Username]\AppData\Local\[ApplicationName]\[AssemblyName][hash]\[Version\)Configurationconfig=ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerU

c# - 有没有像 "user-defined encoding fallback"这样的东西

当使用ASCII编码并将字符串编码为字节时,ö之类的字符将生成?。Encodingencoding=Encoding.GetEncoding("us-ascii");//orEncodingencoding=Encoding.ASCI;data=encoding.GetBytes(s);我正在寻找一种方法来用不同的字符替换这些字符,而不仅仅是问号。示例:ä->aeö->oeü->ueß->ss如果无法用多个字符替换一个字符,如果我能用一个字符替换它们,我会接受(ö->o)现在有几种EncoderFallback的实现,但是我不明白它们是如何工作的。一个快速而肮脏的解决方案是在将字符串提

c# - MVC 错误 : The model item passed into the dictionary is null

我只是想建立一个View,但我收到以下错误:System.InvalidOperationException:Themodelitempassedintothedictionaryisnull,butthisdictionaryrequiresanon-nullmodelitemoftype'System.DateTime现在,我知道为什么会出现这种情况,数据库中的特定字段是空值,但它应该是空值,因为这是稍后编辑的内容。这是我的代码:ActionpublicActionResultView(Int64?Id){ModelContainerctn=newModelContainer();

c# - 当部分 View 位于共享文件夹中时,ASP.NET MVC '@model dynamic' 无法识别模型属性

不重复:MVCRazordynamicmodel,'object'doesnotcontaindefinitionfor'PropertyName'根据那里的答案,AccordingtoDavidEbbo,youcan'tpassananonymoustypeintoadynamically-typedviewbecausetheanonymoustypesarecompiledasinternal.SincetheCSHTMLviewiscompiledintoaseparateassembly,itcan'taccesstheanonymoustype'sproperties.为什

c# - 扩展 ASP.NET 身份角色 : IdentityRole is not part of the model for the current context

我正在尝试在我的MVC5应用程序中使用新的ASP.NETIdentity,特别是我正在尝试将ASP.NETIdentity集成到现有数据库中。我已经阅读了有关DBFirst和ASP.NETIdentity的SO问题/答案,并且遵循了所有建议我仍然无法向我的数据库添加角色,尽管我在添加用户时没有问题。这是我的代码:varcontext=newPayrollDBEntities();varroleManager=newRoleManager(newRoleStore(context));boolroleExists=roleManager.RoleExists(roleDto.Name);

c# - ASP.NET MVC : Views using a model type that is loaded by MEF can't be found by the view engine

我正在尝试创建一个框架,以允许将Controller和View动态导入到MVC应用程序中。到目前为止,它是这样工作的:我正在使用.NET4、ASP.NETMVC3RC和RazorViewEngine每个项目都使用MEF导出和导入Controller-我将给定项目中的一组Controller和View称为“模块”BuildManager使用应用前启动方法和BuildManager.AddReferencedAssembly动态引用使用MEF发现的程序集。使用构建事件将二进制文件(来自导出项目)和View复制到目标项目的文件夹结构中使用自定义Controller工厂选择Controller

c# - OData 和 WebAPI : Navigation property not present on model

我正在尝试使用EntityFramework、WebAPI、OData和Angular客户端组合一个简单的玩具项目。一切正常,除了我在其中一个模型上放置的导航属性似乎不起作用。当我使用$expand调用我的API时,返回的实体没有它们的导航属性。我的类是Dog和Owner,看起来像这样:publicclassDog{//Properties[Key]publicGuidId{get;set;}publicStringName{get;set;}[Required]publicDogBreedBreed{get;set;}publicintAge{get;set;}publicintWe

c# - 如何以编程方式获取 user.config 文件的位置?

我想在我的Windows窗体应用程序中显示user.config文件的位置,以便用户可以轻松找到它。我了解路径是如何创建的,感谢:CanIcontrolthelocationof.NETusersettingstoavoidlosingsettingsonapplicationupgrade?.但是,如果这种情况发生变化,我宁愿不必在我的应用程序中构建路径,尤其是如果有一种获取user.config文件位置的简单方法。 最佳答案 试试这个:varconfig=ConfigurationManager.OpenExeConfigura

c# - “模型”与声明“System.Web.Mvc.WebViewPage<TModel>.Model”冲突

我想显示以下客户对象。publicClassCustomer{publiclongId{get;set;}publicstringName{get;set;}publicAddressAddressInfo{get;set;}}publicclassAddress{publicstringDetails{get;set;}publicCityCityInfo{get;set;}publicRegionRegionInfo{get;set;}}并且有一个Controller返回给客户查看publicActionResultGetCustomer(longId){returnView("C

c# - Model 和 ViewModel 的验证最佳实践

我有单独的模型和View模型类。其中viewmodel类仅进行UI级别验证(引用:Validation:ModelorViewModel)。我可以在Controller中验证模型(vewmodel)是否有效。问:如何验证模型(带有数据注释的主要实体)。我没有使用模型对象开发View模型。只需复制属性并添加该特定View中可能需要的所有属性。//ModelClasspublicclassUser{[Required]publicstringEmail{get;set;}[Required]publicDateTimeCreated{get;set;}}//ViewModelClasspu