本地创建的VS 2013解决方案是否保留用户信息? [英] Do VS 2013 solutions created locally retain user information?

查看:71
本文介绍了本地创建的VS 2013解决方案是否保留用户信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个运行存储过程的项目,以确定用户的权限以及他们应该看到的内容。



我在本地测试了我的网站,清理并构建了解决方案,将其发布到m桌面,然后将文件移动到测试服务器。



一切正常。我更改了自己的用户权限,重新登录到测试服务器,但它仍然显示我以前的权限!



我在页面上输出user.identitiy,有另一个用户登录,看到了正确的用户名,但仍然是我的权限!



我已经使用TRIPLE检查并验证了我的用户信息在存储的proc调用中不是硬核做的而且它不是.a



当我构建并发布覆​​盖用户名信息的解决方案时,我错过了一些设置吗?



什么我试过了:



我搜索了Google,验证了我的代码,搜索了这个知识库。

解决方案

我的猜测是检查权限的存储过程代码有错误!

你说你验证了我的代码,但从未声明过您尝试并且能够验证它识别以外的任何您的权限!



你能来吗?验证本地系统上的那么多

然后再次尝试移动到测试服务器。

如果失败,那么我建议检查您的不是您用户和手动s的相关数据库表模仿(在纸上!)那个用户的存储过程。



这将是一个很好的,老式的调试!

Matt,



我确实尝试过验证它确定了除我的权限以外的任何东西。



下面是我的Main.aspx页面和Main.aspx.cs页面的代码。当Main.aspx页面在生产服务器上加载但是无法识别测试服务器上的更改时,这是非常简单的逻辑运行正常 - 权限似乎默认为我自己的。我检查以确保当我从桌面发布到测试服务器时我不会意外地传递本地客户端控件而我不是:



页面名称  Main.aspx 

<%@ Page 标题 = 语言 = C# MasterPageFile = 〜/ Site.Master AutoEventWireup = true CodeBehind = Main.aspx.cs 继承 = MyWebPage.WebForm2 %>
<%@ 注册 assembly = Microsoft.ReportViewer.WebForms,Version = 11.0.0.0,Culture = neutral,PublicKeyToken = 89845dcd8080cc91 命名空间 = Microsoft.Reporting.WebForms tagprefix = rsweb %>

这是在Main.aspx.cs页面上:

使用System;
使用System.Collections;
使用System.Collections.Generic;
使用System.Linq;
使用System.Data;
使用System.Web;使用System.Web.Security
;
使用System.Web.UI;
使用System.Web.UI.HtmlControls;
使用System.Web.UI.WebControls.WebParts;
使用System.Web.UI.WebControls;
使用System.Security.Principal;
使用System.Data.SqlClient;
使用System.Data.Sql;
使用System.Configuration;

命名空间MyWebPage.Main
{

公共部分类WebForm2:System.Web.UI.Page
{
protected void Page_Load(对象发送者,EventArgs e)
{
if(!IsPostBack)
{

var username = User.Identity.Name;


SqlConnection MyConnection = new SqlConnection(server = ServerName \\sql2008; database = DatabaseName; Trusted_Connection = True;);

SqlDataAdapter MyDataAdapter = new SqlDataAdapter(SP_Name,MyConnection);

MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;

MyDataAdapter.SelectCommand.Parameters.Add(new SqlParameter(@ username,SqlDbType.VarChar,40));

MyDataAdapter.SelectCommand.Parameters [@ username]。Value =(username);

MyDataAdapter.SelectCommand.Parameters.Add(new SqlParameter(@ userrole,SqlDbType.VarChar,40));

MyDataAdapter.SelectCommand.Parameters [@ userrole]。Direction = ParameterDirection.Output;

DataSet DS = new DataSet();

MyConnection.Open();

MyDataAdapter.Fill(DS,UsersRole);

Session.Add(角色,DS);

string userrole = null;

userrole = MyDataAdapter.SelectCommand.Parameters [1] .Value.ToString();

string role1 =Admin;
string role2 =用户;
string role3 =经理;
string role4 =PowerUser;



//TextBox1.Text = MyDataAdapter.SelectCommand.Parameters [1] .Value.ToString();

// Label1.Text = MyDataAdapter.SelectCommand.Parameters [1] .Value.ToString();


if(userrole == role1)
{
Server.Transfer(Main.aspx,true);
}
else if(userrole == role2)
{
Server.Transfer(UserMainPage.aspx,true);
}
else if(userrole == role3)
{
Server.Transfer(ManagerMainPage.aspx,true);
}
else if(userrole == role4)
{
Server.Transfer(PowerUserMainPage.aspx,true);
}

其他
{
Server.Transfer(NewUserMainPage.aspx,true);
}


MyConnection.Close();
}
}


}


}


I created a project that runs a stored procedure to determine the user 's permissions and what they should see.

I tested my site locally, cleaned and built the solution, published it to m desktop, then moved the files over to the test server.

Everything works. I changed my own user permissions, logged back in to the test server but it still shows my previous permissions!

I output the user.identitiy on the page, had another user log in, saw the right user name but still my permissions!

I have used TRIPLE checked and verified my user info is not hardcore do in the stored proc call and it isn't.a

Is there some setting I missed when I built and published my solution that is overriding the user name information??

What I have tried:

I have searched Google, verified my code, searched this knowledge base.

解决方案

My guess is that the stored procedure code that is checking the permissions has a bug!
You said that you "verified my code", but never stated that you tried and were able to verify that it ever identified anything other than your permissions!

Can you verify that much on your local system?
Then try again with moving to the test server.
If that fails, then I suggest examining the relevant DB tables for your not you user and manually simulating (on paper!) the stored procedure for that user.

It's just going to be good, old fashioned debugging!


Matt,

I did try and verify that it identified anything other than my permissions.

Below is the code to my Main.aspx page and my Main.aspx.cs page. It is pretty simple logic that runs fine when the Main.aspx page loads on the production server but won't recognize changes on the test server - the permissions seem to default to my own. I checked to be sure I wasn't accidentally passing local Client controls when I published from my desktop to the test server and I wasn't:

Page Name is Main.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Main.aspx.cs" Inherits="MyWebPage.WebForm2"%>
<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>

This is on the Main.aspx.cs page:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using System.Security.Principal;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Configuration;

namespace MyWebPage.Main
{

    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                var username = User.Identity.Name;
                

                SqlConnection MyConnection = new SqlConnection("server=ServerName\\sql2008;database=DatabaseName;Trusted_Connection=True;");

                SqlDataAdapter MyDataAdapter = new SqlDataAdapter("SP_Name", MyConnection);

                MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;

                MyDataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@username", SqlDbType.VarChar, 40));

                MyDataAdapter.SelectCommand.Parameters["@username"].Value = (username);

                MyDataAdapter.SelectCommand.Parameters.Add(new SqlParameter("@userrole", SqlDbType.VarChar, 40));

                MyDataAdapter.SelectCommand.Parameters["@userrole"].Direction = ParameterDirection.Output;

                DataSet DS = new DataSet();

                MyConnection.Open();

                MyDataAdapter.Fill(DS, "UsersRole");

                Session.Add("Role", DS);

                string userrole = null;

                userrole = MyDataAdapter.SelectCommand.Parameters[1].Value.ToString();

                string role1 = "Admin";
                string role2 = "User";
                string role3 = "Managers";
                string role4 = "PowerUser";
             
              

                //TextBox1.Text = MyDataAdapter.SelectCommand.Parameters[1].Value.ToString();

                //Label1.Text = MyDataAdapter.SelectCommand.Parameters[1].Value.ToString();


                if (userrole == role1)
                {
                    Server.Transfer("Main.aspx", true);
                }
                else if (userrole == role2)
                {
                    Server.Transfer("UserMainPage.aspx", true);
                }
                else if (userrole == role3)
                {
                    Server.Transfer("ManagerMainPage.aspx", true);
                }
                else if (userrole == role4)
                {
                    Server.Transfer("PowerUserMainPage.aspx", true);
                }
               
                else
                {
                    Server.Transfer("NewUserMainPage.aspx", true);
                }


                MyConnection.Close();
            }
        }

       
        }

        
    }


这篇关于本地创建的VS 2013解决方案是否保留用户信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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