我在使用登录控件登录时收到错误 [英] i am getting the error while login with login control

查看:57
本文介绍了我在使用登录控件登录时收到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与c#和SQL server express 2008有关。我在实时服务器上执行功能..我的应用程序与实时服务器工作正常,我能够从服务器获取并显示数据到我的网站。我唯一的问题是登录时使用登录控件。我在登录时收到以下错误。



建立与SQL Server的连接时发生网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。 (提供者:SQL网络接口,错误:26 - 查找指定的服务器/实例时出错)



源错误:


第26行:if(string.IsNullOrEmpty(Request.QueryString [ReturnUrl]))
第27行:{
第28行:if(Roles.IsUserInRole(Login1.UserName) ,admin))
第29行:Response.Redirect(〜/ admin / add-product.aspx);
第30行:否则

i已在登录控制的logged_in事件上编写代码,如下所示


if(string.IsNullOrEmpty(Request.QueryString [ ReturnUrl]))
{
if(Roles.IsUserInRole(Login1.UserName,admin))
Response.Redirect(〜/ admin / add-product.aspx);
else
Response.Redirect(〜/ ProfileInfo.aspx);
}


i我无法理解问题是什么..因为我可以自由执行任何其他功能..



当我从本地主机与实时服务器连接时,还有一件事可以正常工作......





我的网络配置文件如下所示..





 <   location     path   =  admin >  
< system.web >
< 授权 >
< allow 角色 = admin / >

< deny 用户 = * / >
< / authorization >
< / system.web >
< span class =code-keyword><
/ location >
< system.web >

解决方案

可能在您的本地开发服务器中存在SQLExpress且您的应用程序正在使用该数据库使用attachdb方法,但在您的生产服务器中可能是不存在SQLExpress。



希望这会对你有帮助。


检查web.config中你的会员提供者连接字符串

My problem is related to c# and SQL server express 2008. i am performing functions on the live server.. my application is working fine with the live server, i am able to fetch and display data from the server into my website.. the only problem which i am having is while login with login control. i am getting the following error while login..

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Source Error:


Line 26:         if (string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]))
Line 27:         {
Line 28:             if (Roles.IsUserInRole(Login1.UserName, "admin"))
Line 29:                 Response.Redirect("~/admin/add-product.aspx");
Line 30:             else

i have written code on logged_in event of login control like below


        if (string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]))
        {
            if (Roles.IsUserInRole(Login1.UserName, "admin"))
                Response.Redirect("~/admin/add-product.aspx");
            else
                Response.Redirect("~/ProfileInfo.aspx");
        }


i am not able to understand what's the problem.. because i am free to perform any other function..


One more thing when i connect from local host with the live server then it works fine...


My web config file is like below..


<location path="admin">
  <system.web>
    <authorization>
      <allow roles="admin" />

      <deny users="*"/>
    </authorization>
  </system.web>
</location>
<system.web>

解决方案

Probably in your local development server SQLExpress is present and your application is using that db using attachdb method but in your production server may be SQLExpress is not present.

Hope this will help you.


Check your membership provider connection string in web.config


这篇关于我在使用登录控件登录时收到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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