我如何限制未经登录进入网站的用户 [英] how i restrict the user who enter the site without login

查看:64
本文介绍了我如何限制未经登录进入网站的用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何限制未经登录进入站点的用户

how i restrict the user who enter the site without login

推荐答案

修改您的web.config文件,请注意授权"部分

http://www.developerfusion.com/article/5385/highperformance-net -application-development-architecture/5/ [
Amend your web.config file, pay attention to the ''Authorisation'' section

http://www.developerfusion.com/article/5385/highperformance-net-application-development-architecture/5/[^]

<authorization>
   <!-- General application authorization -->
   <allow verbs="POST" users="Jimmy" roles="Administrators" />
   <allow verbs="GET" users="Peter" roles="Debugger Users" />
   <!-- URL Authorization -->
   <allow users="domain1\user, domain2\group" />
   <!--Deny anonymous or All Users-->
   <deny users="? | *" />
 </authorization>



在此部分,您可以允许\根据凭据,组成员身份等拒绝用户



This is the section where you can allow \ deny users based on credentials, group membership etc


<pre lang="xml">&lt;authentication mode=&quot;Forms&quot;&gt;
            &lt;forms defaultUrl=&quot;Secured/Default.aspx&quot; loginUrl=&quot;Login.aspx&quot;&gt;
      &lt;/forms&gt;
        &lt;/authentication&gt;</pre>

<pre lang="xml">&lt;system.web&gt;
            &lt;authorization&gt;
                &lt;deny users=&quot;?&quot;/&gt;
            &lt;/authorization&gt;
        &lt;/system.web&gt;</pre>
in the code behind
<pre lang="cs">protected void btn_Submit_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text == &quot;UserName&quot;)
            {
                if (TextBox2.Text == &quot;Password&quot;)
                {
                   // Response.Redirect(&quot;~/Secured/Secured2.aspx&quot;);
                    FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false);
                }
                else
                {
                    Label1.Text = &quot;Enter Correct Password&quot;;
                }
            }
            else
            {
                Label1.Text = &quot;Enter Correct User Name&quot;;
            }
        }</pre>
<pre lang="sql">Use Forms Authentication for that
try this link
Link [^]</pre>


我认为您需要阅读一些有关身份验证及其在IIS环境中如何工作的信息.您所要求的内容不应仅在代码和SQL Server中处理.您应该合并内置的IIS身份验证过程以实现您的目标.
查看一些
I think you need to read up a bit on authentication and how it works in an IIS environment. What you are asking for should not be handled only in code and SQL Server. You should incorporate built in IIS authentication processes to achieve your goal.
Check out some of these links.


这篇关于我如何限制未经登录进入网站的用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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