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

  • Home
  • SEARCH
  • 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 8907277
In Process

The Archive Base Latest Questions

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

I am using basic authentication for my web api which has been hosted on

  • 0

I am using basic authentication for my web api which has been hosted on a server. It works fine on my local with the basic authentication. But when i hosted it to the server it results in 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 *

And it works fine on the server also when i remove the basic authentication.

My connection string

<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" />    

Am using system.web.providers for the basic auth so i found this in my web.config

<!--
        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>

I did change the mode to custom and i suppose my connection string is connected to an sql server rather than sql server express?? am not sure about that!

And interestingly its showing an error at connectionStringName saying that “the attribute is not allowed”? But in my local VM it doesnt throw any error like that and thats y i guess the basic auth is working fine on my local VM.

Can anyone please tell me where i might be going wrong. Any suggestions at all would be deeply appreciated. I have been banging my head about it all day 🙁

  • 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:52:30+00:00Added an answer on June 15, 2026 at 2:52 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

Using Basic Authentication, and the asp.net Web-Api, where JSON Get/Post's to my API, I
I am using jboss server. I want to do BASIC authentication using web.xml file.
I refactored an attribute, which implements Basic Http Authentication in the Web api, to
I have an API deployed on a server that's now protected using basic authentication.
I am using basic authentication for my web api and am getting the following
I am using tomcat basic authentication for my web app: I added following lines
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 have a web site using https and basic authentication. User is automatically authenticated

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.