我们有几个.NET项目,我们在配置文件中存储某些设置.现在每个开发人员都有自己的配置文件,这些配置文件略有不同(连接到本地数据库的不同连接字符串,不同的WCF端点等)
目前我们倾向于检查app/web.config文件并修改它们以满足我们的需求.这会导致许多问题,因为从tfs获取最新版本时,有时会有人检查自己的设置或松散自定义配置.
我的问题是:你如何处理这样的情况?或者你根本没有这个问题?
在android中,如何使用http将文件(数据)从移动设备发送到服务器.
我试图了解Web.xml中会话超时的会话配置的真正目的.
<!-- Session Configuration -->
<session-config>
<session-timeout>60</session-timeout>
</session-config>
Run Code Online (Sandbox Code Playgroud)
现在让我告诉你我的问题.
我的应用程序是导入/上传.txt文件,由于需要导入数百万条记录,因此该文件的使用时间超过1小时.但是,虽然我的应用程序仍在导入正在进行的.txt文件,但会话在1小时后超时.应用程序在后台执行某项任务时,此类应用程序不应超时.
我创建了一个Windows服务程序,我希望我的错误严格写入Windows eventLog.所以我从代码项目文章中遵循了以下步骤:
http://www.codeproject.com/KB/dotnet/simplewindowsservice.aspx
但是,当我启动或停止服务时,我没有在事件查看器窗口中创建的事件日志中看到任何自定义日志消息.另外,如何指定消息是由于错误还是仅仅是信息?
我试图aspnetuser从不同的控制器(而不是accountcontroller)设置表中的列的值.我一直试图访问,UserManager但我不知道如何做到这一点.
到目前为止,我已经在控制器中尝试了以下内容我想用它:
ApplicationUser u = UserManager.FindById(User.Identity.GetUserId());
u.IsRegComplete = true;
UserManager.Update(u);
Run Code Online (Sandbox Code Playgroud)
这不会编译(我想因为UserManager还没有实例化控制器)
我还尝试创建一个公共方法,AccountController以接受我想要更改值的值并在那里做,但我无法弄清楚如何调用它.
public void setIsRegComplete(Boolean setValue)
{
ApplicationUser u = UserManager.FindById(User.Identity.GetUserId());
u.IsRegComplete = setValue;
UserManager.Update(u);
return;
}
Run Code Online (Sandbox Code Playgroud)
如何访问和编辑帐户控制器之外的用户数据?
更新:
我尝试在其他控制器中实例化UserManager,如下所示:
var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(db));
ApplicationUser u = userManager.FindById(User.Identity.GetUserId());
Run Code Online (Sandbox Code Playgroud)
我的项目符合(有点兴奋),但当我运行代码时,我收到以下错误:
Additional information: The entity type ApplicationUser is not part of the model for the current context.
Run Code Online (Sandbox Code Playgroud)
更新2:
我已将该功能移至IdentityModel(不要问我在这里抓住吸管),如下所示:
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) …Run Code Online (Sandbox Code Playgroud) asp.net-mvc actioncontroller asp.net-mvc-5 asp.net-identity-2
我正在尝试在我的ASP.NET应用程序中使用Windows身份验证.每当我尝试查看应用程序时,它都会将我发送到登录页面.如何在不通过浏览器手动登录的情况下使其工作?
<system.web>
<authentication mode="Windows"></authentication>
<anonymousIdentification enabled="false"/>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
<customErrors mode="Off"></customErrors>
<identity impersonate="true"></identity>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime />
</system.web>
Run Code Online (Sandbox Code Playgroud)
Most likely causes:
No authentication protocol (including anonymous) is selected in IIS.
Only integrated authentication is enabled, and a client browser was used that does not support integrated authentication.
Integrated authentication is enabled and the request was sent through a proxy that changed the authentication headers before they reach the Web server. …Run Code Online (Sandbox Code Playgroud) 我一直在阅读Alexandrescu的书,现代C++设计,我对他使用的技术印象深刻,所以我想在我的应用程序中添加Loki库.
然而,经过进一步的调查,我看到我已经在使用的提升提供了很多类似的功能(不是全部,但是,例如,我无法在boost中找到单例)
由于基于策略的设计和仿函数,我最感兴趣的是使用loki.
对我而言,boost和loki都有利有弊.我对loki的主要关注是糟糕的文档(图书馆不再与书籍联系在一起了)但在我看来,loki比某些领域的提升更强大,更灵活(我可能错了)
在选择使用boost或loki作为仿函数和策略之前,我想知道在现实生活中使用它们的人的意见.
有时在纸上看起来非常好但是当你真正使用它们时会有一些缺点:)
我目前正在为汽车经销商开展一个大项目,我陷入两难境地.
我应该使用ASP.NET身份还是旧式的FormsAuthentication?
我需要能够通过2个提供商登录.首先,用户总是在数据库中,但是我们检查它是否是LDAP用户,如果是,则通过LDAP进行身份验证(我使用WebService作为具有Login方法的用户).
这是我的登录方法:
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Login(LoginModel model)
{
if (ModelState.IsValid)
{
var userInDb = this.db.Users.FirstOrDefault(u => u.Username == model.username);
if (userInDb != null)
{
// USER EXISTS
if (userInDb.IsLdap)
{
try
{
// IS LDAP POWERED, IGNORE PASSWORD IN DB
using (var ws = WebServiceClient.Factory(model.GetDomain()))
{
// MAKE AUTH
var result = await ws.Login(model.GetUsername(), model.password);
if (result.Success)
{
// USER IS LEGAL
FormsAuthentication.SetAuthCookie(model.username, model.remember);
return RedirectToAction("Init");
}
else
{
// USER IS ILLEGAL
ModelState.AddModelError("", "Username …Run Code Online (Sandbox Code Playgroud) 当我使用SmtpClient的SendAsync发送电子邮件时,如何smtpclient正确处理实例?
让我们说:
MailMessage mail = new System.Net.Mail.MailMessage()
{
Body = MailBody.ToString(),
IsBodyHtml = true,
From = new MailAddress(FromEmail, FromEmailTitle),
Subject = MailSubject
};
mail.To.Add(new MailAddress(i.Email, ""));
SmtpClient sc = new SmtpClient(SmtpServerAddress);
//Add SendAsyncCallback to SendCompleted
sc.SendCompleted += new SendCompletedEventHandler(SendAsyncCallback);
//using SmtpClient to make async send (Should I pass sc or mail into SendAsyncCallback?)
sc.SendAsync(mail, sc);
Run Code Online (Sandbox Code Playgroud)
在SendAsyncCallback方法中,我应该打电话sc.Dispose(),还是mail.Dispose()?
我检查了MSDN文件,一个例子调用了MailMessage.Dispose(),但是这个dispose方法还会配置SmtpClient实例吗?
非常感谢.
我有一个Android应用程序,使用WEB API Web服务与.NET服务器通信.目前,我在服务器和客户端上传输对象.
Java类
public class UserAction {
private String username;
private String action;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
}
Run Code Online (Sandbox Code Playgroud)
我在服务器端的C#类
public class UserActionTO
{
public string Username { get; set; }
public string Action { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我希望在两个应用程序之间共享这些模型.
我发现这个问题讨论分享类型,但我的情况有点不同.我应该在Web API服务和它的客户端之间共享类型吗?还有什么其他选择?
我正在考虑创建一个C++ DLL,我的android应用程序和C#应用程序都可以使用它.这是我最好的选择吗?
编辑 我正在使用JSON传输数据
c# ×6
android ×2
asp.net ×2
java ×2
app-config ×1
asp.net-mvc ×1
boost ×1
c++ ×1
dispose ×1
events ×1
functor ×1
http ×1
iis ×1
iis-express ×1
java-ee ×1
logging ×1
loki ×1
post ×1
sendasync ×1
service ×1
servlets ×1
smtpclient ×1
web-config ×1
web-services ×1
web.xml ×1