如何在asp.net中的特定时间后拒绝登录 [英] how to decline login after specific time in asp.net

查看:98
本文介绍了如何在asp.net中的特定时间后拒绝登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..
我想拒绝登录假设在下午6:30之后...我应该如何在asp.net中使用c#
执行此操作?
请帮帮我..

提前谢谢.

问候,
Vishal

Hi..
I want to decline Login suppose after 6:30 PM...how should i do this in asp.net with c#

Please help me..

Thanks in advance.

Regards,
Vishal

推荐答案

(很多)一种方法是检查登录按钮的click事件的时间.将时间与您的timem进行比较,如果超过该时间,则减少时间.您可能还需要考虑用户的时区.

请参见此处 [此处 [ ^ ].
One way (of many) might be to check the time on the click event of the login button. Compare the time to your timem, if it is more than that time, decline. You might also want to take into account the timezone of the user.

See here[^] for a few different ways to compare times.

And here[^].


http://msdn.microsoft. com/en-us/library/ff647405.aspx [ ^ ]


1.通过确保在< identity>上将模拟设置为false,检查您的ASP.NET应用程序未配置为模拟. Web.config文件中的元素.
...

http://msdn.microsoft.com/en-us/library/ff647405.aspx[^]


1.Check that your ASP.NET application is not configured for impersonation by ensuring that impersonate is set to false on the <identity> element in the Web.config file.
...

<system.web>
 ...
 <authentication mode="Windows"/>
 <identity impersonate="false"/>
 ...
</system.web>
...


2.获取经过身份验证的用户的Windows令牌.


2.Obtain the authenticated user''s Windows token.

IIdentity WinId= HttpContext.Current.User.Identity;
WindowsIdentity wi = (WindowsIdentity)WinId;


3.模拟完成后,使用经过身份验证的用户的Windows令牌临时模拟原始用户,并从当前线程中删除模拟令牌.


3.Use the authenticated user''s Windows token to temporarily impersonate the original user and remove the impersonation token from the current thread when you are finished impersonating.

// Temporarily impersonate the original user.
WindowsImpersonationContext wic = wi.Impersonate();
try
{
  // here you will check time
  // Access resources while impersonating.
}
catch
{
  // Prevent exceptions propagating.
}
finally
{
  // Revert impersonation.
  wic.Undo();
}





本文将帮助您解决此问题.





This article will help you to solve this problem.


这篇关于如何在asp.net中的特定时间后拒绝登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆