Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8906745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:44:03+00:00 2026-06-15T02:44:03+00:00

I am using basic authentication for my web api and am getting the following

  • 0

I am using basic authentication for my web api and am getting the following error

*{“Message”:”An error has occurred.”,”ExceptionMessage”:”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: Named Pipes Provider, error: 40 – Could not open a connection to SQL *

It works absolutely fine when i remove the basic auth implementation from my APIs. So am guessing the problem should be something related to system.web.providers which am using for the basic auth implementation.

This is how my connection string looks like

<connectionStrings>
<add name="DefaultConnection" connectionString="Password=password;Persist Security Info=True;User ID=wbuser;Initial Catalog=WinBouts_com;Data Source=WINBOUTSAPIVM"
  providerName="System.Data.SqlClient" />
<add name="WinBoutsConnectionString" connectionString="Password=password;Persist Security Info=True;User ID=wbuser;Initial Catalog=WinBouts_com;Data Source=WINBOUTSAPIVM"
  providerName="System.Data.SqlClient" />    

And i see an error in my web.config where a session provider is added. The error says “the connectionStringName attribute is not allowed”. But if i remove it then it asks for the connectionStringName. This is the code for it.

 <!--
        If you are deploying to a cloud environment that has multiple web server instances,
        you should change session state mode from "InProc" to "Custom". In addition,
        change the connection string named "DefaultConnection" to connect to an instance
        of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
  -->
<sessionState mode="Custom" customProvider="DefaultSessionProvider">
  <providers>
    <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="WinBoutsConnectionString" />
  </providers>
</sessionState>

Can anyone please tell me where i might be going wrong? Any suggestions or ideas would be deeply appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:44:04+00:00Added an answer on June 15, 2026 at 2:44 am

    Finally Resolved the issue. The problem was in my Basic Authentication filter class.

    private bool TryGetPrincipal(string username, string password, out IPrincipal principal)
        {      string connectionString = ConfigurationManager.ConnectionStrings["WinBoutsConnectionString"].ConnectionString;    
    
            username = username.Trim();
            password = password.Trim();
    
            //only supporting SSO login atm
           // var valid = Membership.Provider.ValidateUser(username, password);
            serviceContext = new WinBoutsDataContext<DataAccess.Model.UserInfo>(connectionString);
            userRepository = new UserRepository(serviceContext);
    
            var valid = this.userRepository.ValidateAccount(username, password);
    
            if (valid)
            {
                // once the user is verified, assign it to an IPrincipal with the identity name and applicable roles
                principal = new GenericPrincipal(new GenericIdentity(username), System.Web.Security.Roles.GetRolesForUser(username));
                return true;
            }
    
            //user wasn't found, unauthorised
            principal = null;
            return false;
        }
    

    I have hardcoded my DataContext here but earlier i didnt pass my connection string into it. I just went for the default constructor of the WinBoutsDataContext which didnt work when i put the code on to the server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using basic authentication for my web api which has been hosted on
Using Basic Authentication, and the asp.net Web-Api, where JSON Get/Post's to my API, I
I am using tomcat basic authentication for my web app: I added following lines
I am using jboss server. I want to do BASIC authentication using web.xml file.
Using UIWebview with basic authentication ( authentication works ) however I am not getting
I'm trying to use the new WCF Web API Preview 6 with Basic Authentication.
My web app has multiple authentication managers (one for API one for WEB access).
I refactored an attribute, which implements Basic Http Authentication in the Web api, to
I have a web site using https and basic authentication. User is automatically authenticated
I have an API deployed on a server that's now protected using basic authentication.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.