我使用Identity v2.0.0.0,EF 6,Castle Windsor IOC Container,Microsoft SQL Server 2005,使用我的asp.net MVC5 Web应用程序来解决这个问题
我试图通过使用UserManagerExtensions,FindById()方法来获得登录用户当前但它抛出一个错误"System.NotSupportedException:开始之前的异步操作完成之前这方面的一个第二次运行使用'等待’,以确保这一点.在调用此上下文中的另一个方法之前已完成任何异步操作.不保证所有实例成员都是线程安全的"
我从堆栈跟踪了解的是,"AsyncHelper.RunSync()"导致的问题,我不会在我的代码,但"FindById()"使用AsyncHelper参考使用任何非同步功能- : HTTP://www.symbolsource.组织/ MyGet /元/ aspnetwebstacknightly /项目/ Microsoft.AspNet.Identity.Core/2.0.0-beta1-140129 /发行/默认/ Microsoft.AspNet.Identity.Core/Microsoft.AspNet.Identity.Core /扩展/ UserManagerExtensions. CS?ImageName = Microsoft.AspNet.Identity.Core
似乎是,我使用用户在我的应用程序的不同部分的细节,当前登录的这个标识错误的信息很少,这个错误似乎当呼叫到达GetCurrentLoggedInUser我在服务层()函数随机出现.请帮忙....
我的代码和堆栈跟踪如下----注意:我在此处发现了另一个类似类型的事件:https://aspnetidentity.codeplex.com/workitem/2408
Global.asax中:
.Register(Component
.For<UserManager<ApplicationUser>>()
.UsingFactoryMethod((kernel, creationContext) =>
new TempoUserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext(ASPUserDatabaseConnectionString))))
.LifestylePerWebRequest()
)
.Register(Component
.For<RoleManager<IdentityRole>>()
.UsingFactoryMethod((kernel, creationContext) =>
new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(new ApplicationDbContext(ASPUserDatabaseConnectionString))))
.LifestylePerWebRequest()
)
Run Code Online (Sandbox Code Playgroud)
服务层代码:
public class GenericService
{
protected IRepository _repository;
protected UserManager<ApplicationUser> _userManager;
public GenericService(IRepository repository, UserManager<ApplicationUser> userManager)
{
_repository = repository;
_userManager = userManager;
}
public …Run Code Online (Sandbox Code Playgroud) c# asp.net-mvc entity-framework asp.net-mvc-5 asp.net-identity
我正在创建一个函数来返回'0'或'1',具体取决于嵌套if else语句的结果.使用MSSQL.
ALTER FUNCTION udf_check_names_starting_with_quotationmark
(@string NVARCHAR(100))
RETURNS INT
AS
BEGIN
DECLARE @condition INT
SET @string = LTRIM(@string)
SET @string = RTRIM(@string)
IF (PATINDEX('"%', @string) !=0)
BEGIN
SET @condition = 1
END
ELSE IF (PATINDEX('%"%', @string) !=0)
BEGIN
SET @condition=1
END
ELSE IF (PATINDEX('%"', @string) !=0)
BEGIN
SET @condition = 1
END
ELSE
BEGIN
SET @condition=0
END
RETURN @condition
END
Run Code Online (Sandbox Code Playgroud)
这一切都很好.有没有更好的方法来实现这一点(我尝试使用OR但SQL编辑器显示错误,而不是识别OR).
我正在使用 IntelliJ,添加了 IvyIdea 插件,现在尝试使用 IvyIdea 解决项目(Ant 构建)的依赖关系,但收到有关“UNRESOLVED DEPENDENCIES”的错误。我已经下载并配置了 Ivy 和 Ant。
我可以使用 Ant 命令行解析和构建项目,但不能通过 IDE。我可以看到 ~.ivy2\cache 文件夹已解决了它所抱怨的所有依赖项。
我已经为所有模块配置了“Facets”,以映射到正确的 Ivy 设置和构建属性文件。有谁知道我还有什么可以尝试的吗?
我现在在日志中发现一件事,
loadData of pentaho-kettle#kettle-core;7.1-SNAPSHOT of rootConf=default
using default to resolve pentaho-kettle#kettle-core;7.1-SNAPSHOT
default: Checking cache for: dependency: pentaho-kettle#kettle-core;7.1-SNAPSHOT {default-ext=[default]}
don't use cache for pentaho-kettle#kettle-core;7.1-SNAPSHOT: changing=true
don't use cache for pentaho-kettle#kettle-core;7.1-SNAPSHOT: changing=true
local (useCacheOnly) : no ivy file found for pentaho-kettle#kettle-core;7.1-SNAPSHOT
main: Checking cache for: dependency: pentaho-kettle#kettle-core;7.1-SNAPSHOT {default-ext=[default]}
don't use cache for pentaho-kettle#kettle-core;7.1-SNAPSHOT: changing=true
don't use cache for pentaho-kettle#kettle-core;7.1-SNAPSHOT: changing=true
shared (useCacheOnly) …Run Code Online (Sandbox Code Playgroud) 我正在尝试锻炼以了解如何从不同的类访问列表项并更新它们,我在下面的代码中进行了澄清.
class list
{
private List<Person> people;
public List<Person> People
{
get { return people; }
set { people = value; }
}
}
public partial class Form2 : Form
{
Person p = new Person();
list l = new list();
p.Name = textBox1.Text;
p.Streetaddress = textBox2.Text;
p.Email = textBox3.Text;
p.Birthday = dateTimePicker1.Value;
p.AdditionalNotes = textBox4.Text;
l.People.Add(p);
listView2.Items.Add(p.Name);
}
Run Code Online (Sandbox Code Playgroud)
有Person类,它有实例变量Name,Streetaddress等.
得到一个错误
Nullreference异常未得到处理
请帮我..
我有一个数组和一个循环,我想找到当前项目的索引,以便我可以决定是否在列表框中显示该项目,
string[] papers = new string[7] { "Software Development", "Data Fundamentals", "Information and Communication", "User Support", "Web Fundamentals", "Network Fundamentals", "Computer Fundamentals" };
for (int i = 0; i < papers.Length; i++)
{
int n=papers.Length;
if (n==2)
{
continue;
}
else
{
listView1.Items.Add(papers[i]);
}
}
Run Code Online (Sandbox Code Playgroud)
但我无法实现它,有人可以帮助我吗?或者有更好的方法来做到这一点?
谢谢
我有代码来检索数据库项,并使用J2ME在移动应用程序中显示它.我也使用JSP,这样我的移动应用程序就可以从中获取信息.
我想知道如何检索多个项目?
JavaBean的:
public String doQuery() throws ClassNotFoundException, SQLException {
//register driver
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
//establish connection
Conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/a1electric?user=root&password=raam030");
//Create a Statement object from the Connection
Statement stmt = Conn.createStatement();
String sql = "SELECT JobID FROM employee WHERE employeeID=" +this.jobID;
ResultSet rs = stmt.executeQuery(sql);
String rt = "";
rs.next();
rt = rs.getString("JobID");
Conn.close();
return rt;
}
Run Code Online (Sandbox Code Playgroud)
JSP页面:
<jsp:useBean id="bean0" scope="session" class="data.queryBean"/>
<jsp:setProperty name="bean0" property="jobID" param="jobID"/>
<%= bean0.doQuery() %>
Run Code Online (Sandbox Code Playgroud)
我想检索此员工ID的所有作业ID并显示它.