在大多数情况下,我的webapp需要身份验证才能执行任何操作.有一些页面,即主页,我希望人们无需身份验证即可访问.
具体来说,我想允许匿名访问这些网址:
/home
/default.aspx
Run Code Online (Sandbox Code Playgroud)
我正在使用asp.net MVC和FormsAuthentication.两个网址都指向同一个视图:
/home/index.aspx
Run Code Online (Sandbox Code Playgroud)
这是我在web.config中的当前配置.
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
Run Code Online (Sandbox Code Playgroud)
阅读授权标签的文档,它说"配置Web应用程序的授权,控制客户端对URL资源的访问".看起来我应该能够使用授权标签来指定URL并允许访问.
就像是:
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
<authorization url="/default.aspx">
<allow users="?" />
</authorization>
<authorization url="/home">
<allow users="?" />
</authorization>
Run Code Online (Sandbox Code Playgroud) 我有一个Java应用程序,它需要某些软件(其中一个是Perl)才能运行.我以前用来检测Perl的是:
Runtime.getRuntime().exec("perl Test.pl");
Run Code Online (Sandbox Code Playgroud)
如果有IOException声明没有Perl.
然而,我的一个用户抱怨该应用程序仍然失败,因为他没有将Perl放在他的路径变量中.所以这就是为什么我要问:是否有任何跨操作系统方法来检测用户系统上是否安装了Perl(或任何其他软件)以及程序的路径?
我正在GUI中运行一些后台线程.目前我正在实现个人线程取消代码,但线程中有IsBackground属性,根据MSDN,它们将自行取消.
我知道它会变成令人讨厌的Thread.Abort(),但是在这个后台线程中没有任何东西需要保持正确的状态或需要适当的清理.
如果用户只是在后台线程中间关闭应用程序,我试图避免任何崩溃.由于多线程场景很难测试,我想就此主题发表意见.
基本上,我只是设置IsBackground = True而忘记其余的代码而不是滚动我自己的代码?
我想通过图表来表示我的程序的逻辑,因为程序非常复杂; 我需要一种方法向另一个人解释,为什么以及如何在我的程序中发生某些事情.流程图是唯一的选择吗?
在调试.NET Framework 3.5,WinForms应用程序时,我发现了一些没有名称的"工作线程".
我知道当你打开一个应用程序时,默认情况下你有一个工作线程.但是在调试过程中,当我暂停调试器并查看"线程"窗口时,我看到大约5个以上类似的线程(优先级=正常).
应用程序打开的所有线程都有一个名称,所以这些不是从代码中打开的,至少不是通过Thread.Start()
当我尝试双击时,VS.NET也找不到代码.
这些线程是什么?它们是正常的,还是某些操作会以某种方式留下空线?
它们可以是定时器或类似的非显而易见的控件,函数可以在后台使用临时线程吗?
我正在尝试编写一个Java程序来记录我每5秒使用一次的应用程序(这是一个时间跟踪器应用程序).我需要一些方法来找出当前活动窗口是什么.我找到了KeyboardFocusManager.getGlobalActiveWindow(),但我无法让它正常工作.最好是跨平台解决方案,但如果不存在,那么我正在使用X.Org开发Linux.谢谢.
我有一系列员工ID:
34,35,40,67,54等.
查询我的"员工"表并找到相关员工的所有姓名的最简单方法是什么?
这是一个返回数组中每个id的'name'的查询.
如果我有这个:
Type t = typeof(Dictionary<String, String>);
Run Code Online (Sandbox Code Playgroud)
我怎么得到"System.Collections.Generic.Dictionary"
一个字符串?这是最好/唯一的方法:
String n = t.FullName.Substring(0, t.FullName.IndexOf("`"));
Run Code Online (Sandbox Code Playgroud)
虽然看起来有点像哈希.
我想要这个的原因是我想要一个Type
对象,并产生类似于C#源代码文件中的代码.我正在制作一些文本模板,我需要将类型作为字符串添加到源代码中,并且FullName
属性产生如下内容:
System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089]]
Run Code Online (Sandbox Code Playgroud)
而不是我想要的:
System.Collections.Generic.Dictionary<System.String, System.String>
Run Code Online (Sandbox Code Playgroud)
编辑:好的,这是最终的代码,对我来说似乎有点像黑客,但它有效:
/// <summary>
/// This method takes a type and produces a proper full type name for it, expanding generics properly.
/// </summary>
/// <param name="type">
/// The type to produce the full type name for.
/// </param>
/// <returns>
/// The type name for <paramref name="type"/> …
Run Code Online (Sandbox Code Playgroud) 我正在使用VSTS 2008 + ADO.Net + C#+ .Net 3.5 + SQL Server 2008.我在客户端使用ADO.Net连接到数据库服务器以执行存储过程,然后从存储过程返回结果.
这是我的代码.我有两个关于超时的问题,
如果我没有明确设置任何与超时相关的设置,对于与数据库服务器的连接,是否有任何超时设置(例如,如果在一段默认时间内无法连接到数据库服务器,会有一些超时异常?)?
如果我没有明确设置任何超时相关设置,对于执行存储过程,是否有任何超时设置(例如,如果无法从服务器检索到ADO.Net客户端的结果一段默认时间,则会有一些超时例外?)?
using (SqlConnection currentConnection = new SqlConnection("Data Source=.;Initial Catalog=TestDB;Trusted_Connection=true;Asynchronous Processing=true"))
{
// check current batch conut
currentConnection.Open();
using (SqlCommand RetrieveOrderCommand = new SqlCommand())
{
RetrieveOrderCommand.Connection = currentConnection;
RetrieveOrderCommand.CommandType = CommandType.StoredProcedure;
RetrieveOrderCommand.CommandText = "prc_GetOrders";
RetrieveBatchCountCommand.Parameters.Add("@Count", SqlDbType.Int).Direction = ParameterDirection.Output;
RetrieveBatchCountCommand.ExecuteNonQuery();
int rowCount = Convert.ToInt32(RetrieveOrderCommand.Parameters["@Count"].Value);
}
}
Run Code Online (Sandbox Code Playgroud).net ×4
c# ×2
java ×2
ado.net ×1
detect ×1
diagram ×1
isbackground ×1
mysql ×1
php ×1
python ×1
reflection ×1
sql-server ×1
types ×1
winforms ×1