We are excited to announce that the IIS.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

Cannot connect to MS-SQL-db on IIS6.2 (win8.1) from same PC (from browser)RSS

3 replies

Last post Apr 22, 2021 02:04 AM by samwu

  • Cannot connect to MS-SQL-db on IIS6.2 (win8.1) from same PC (from browser)

    Apr 21, 2021 12:37 AM|indubhushan|LINK

    hello, i'm studying programming, and we have course in asp.net. I decided to host a site on own PC - I have a domain, which is attached to my IP, which is permanent (from provider). So on my PC I have Win8.1 and IIS server (seems to be version 6.2). So, I make simple asp.net app, run it in browser (host in IIS express inside Visual studio or, more important - on IIS server when Visual Studio not running), and it is not really working as expected...

    Problem is: if I compile and run IIS from Visual studio, and open it in browser, it may work - but only when Visual studio is in "debug"mode (I pressed start and keep waiting till I press STOP Program in Visual studio). In this way I open my browser, press a button to connect to database and execute some "select"command, and... it may work. But still buggy, I can't even understand why problems happen differently.

    Worse is when I try to close visual studio, open IIS manager, and add there my folder with site, and attach it to some port on localhost (my internal network/LAN IP starting with 192.168.0...). This way it starts working even worse. I may open it in browser, such site, but seems like only on same PC. But worse is when I press the button to open DB, execute sql command - it seems like not going to connect to DB.

    very strange! I have SQL server and IIS server on very same PC, but I can't login into own DB on same own server! why?

    and even worse happen when I try to login from other computer, on LAN (if it is from other PC on internet - may be even worse, invisible site) - still worse. it seems like I can make the site on other PC visible, so I open broser and page with that button. but when I press same button - it seems like asp.net or IIS server cannot connect to DB.

    I suspect problem is with "Anonymous users" who login from some PC on internet - to my server. So it seems like Windows try to authentificate them as "guests"or "anonymous"etc, and gives unknown kind of acces to them.

    Problem is that I don't reallt know what should I do to make users from other PCs be able to connect to my "home server". I wonder why do they at all need to authentificate on my computer? Why do they need to login to my PC even as guests? it is rather strange!

    I 'll try to explain what I mean. I tried to make sample project on smarteraspnet, and to use it I had to make a user on my PC... so I had to make it have same user name and password as I used to login to smarteraspnet hosting... and even then - when i login to local computer into Windows as user/login (same as on smarteraspnet, I have to stress it, why?) - then I may open SQL SMS manager, and when i write server adress (port), choose additional authentification (sql user + sql password, additionally to windows user/password) - then I can connect to db...

    hey, why oh why I need to make an account on my Windows PC to make someone to log in to my PC just to use my DB?

    let's say if I make some facebook, or similar site with millions of users, does it mean that all such users must be registered as Windows logins in my Windows PC? no. but system of IIS/asp-net/MS-SQL seems like demands it.

    So, problem which I have: i've got error that if I connect from other PC (say client) to my server PC (with asp net site hosted on IIS with sql server as well, SQL  EXPRESS), - then how do I have to do login? this is really strange, because if sql server wants Windows authentification, then it means that if I want anyone on internet to enter my site - the user would also have to make account with same user and password on his local Windows PC? and what if that's not Windows but unix, macos, some phone etc? then it's not possible! so in this context, making anonymous users is something strange...  

    yes, and finally, if I try to open my server (site) from internet (other provider/network, so site is not in same LAN) - then it is invisible at all (though I set settings on router with ports "forwarding"). this really puzzles me a lot...

    I tried to make in similar connection from WinForms / WPF - and it worked. and as far as I remember (it was maybe in summer/autumn) - I also tried to connect from other provider to my server (client and server are in different LANs, having only local IPs) - and still I was able to acces server, because I made port forwarding on router, so PC became visible on that port with SQL server on it...

    I wonder why it is not working the same way? I opened IIS configuration, enabled TCP port (in sql server config manager) - TCP port is default - 1433. Still I can't connect to SQL DB... why? does it have to do anything with EXPRESS edition of SQL server? or just misconfiguration?

    This is even more strange, as it seems like I can't even connect to own website and then from it to SQL DB on very same PC (when I host it not from Visual Studio - IIS express, but from IIS when Visual studio not running) - so sql server not accessible.

    this seems to be issue with "remote connections"for sql server, and anonymous logins. but have no idea how this all to be done properly. my basic understanding, that if I make sql server, and run IIS server on same PC, then IIS/asp must be able to connect as VERY SAME (Windows) user to sql server, and no additional SQL authentification is required... similarly, if I connect from other PC (as client) to server - then I can esily ping it, open server's file system in explorer of client, so that means that i loged in, isn't it? then what is the need of additional authentification

    And still another question, that if I simply post some request to server, why on earth it has anything to do with users? I may save cookie with session/login data, may know the port, IP, but how this can have anything to do with logging in from client's browser (even anonymously) to my Windows server, and also to sql server?

    say, I just want to make user press button, and server has to make "select" from database and show result to anyone, I don't see any need to make new "anonymous user" on my server, and also for DB...   

    I don't understand...

     

    thank you anyone in advance for answers

  • Re: Cannot connect to MS-SQL-db on IIS6.2 (win8.1) from same PC (from browser)

    Apr 21, 2021 05:11 AM|samwu|LINK

    Hi indubhushan,

    indubhushan

    Problem is that I don't reallt know what should I do to make users from other PCs be able to connect to my "home server". I wonder why do they at all need to authentificate on my computer? Why do they need to login to my PC even as guests? it is rather strange!

    Did you get any errors?

    Best regards,

    Sam

    IIS.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
  • Re: Cannot connect to MS-SQL-db on IIS6.2 (win8.1) from same PC (from browser)

    Apr 21, 2021 06:08 AM|indubhushan|LINK

    samwu

    Did you get any errors?

    yes, errors are:

    • - ConnectionString property is not initialized
    • - Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
    • - While connecting to SQL Server error occured, which is related to network or certain instance. Server not found or not available. Make sure that instance is correct and that SQL Server allows remote connections. (provider: SQL Network Interfaces, error: 26 - Error while detecting remote server or instance)
    • - Error while logging in of the user "".

    I can do "select * ..." from database, when run from IIS Express (visual studio). But when I host in IIS server (not IIS Express) on other IP-address (but same PC, 192.168.0.208) - I may get errors above. Also this:

    • - Cannot open DB "ivan", which is queried by username\login. Cannot login. Error logging in user "IIS APPPOOL\myAspNetSite".

    •  

  • Re: Cannot connect to MS-SQL-db on IIS6.2 (win8.1) from same PC (from browser)

    Apr 22, 2021 02:04 AM|samwu|LINK

    Hi indubhushan,

    indubhushan

    • ConnectionString property is not initialized
    • - Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
    • - While connecting to SQL Server error occured, which is related to network or certain instance. Server not found or not available. Make sure that instance is correct and that SQL Server allows remote connections. (provider: SQL Network Interfaces, error: 26 - Error while detecting remote server or instance)
    • - Error while logging in of the user "".

    I can do "select * ..." from database, when run from IIS Express (visual studio). But when I host in IIS server (not IIS Express) on other IP-address (but same PC, 192.168.0.208) - I may get errors above. Also this:

    • - Cannot open DB "ivan", which is queried by username\login. Cannot login. Error logging in user "IIS APPPOOL\myAspNetSite".

    Did you get so many errors at once? you should try to solve the current error first.

    Best regards,

    Sam

    IIS.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >