Publish Web Page on Local Server - c#

I have a Web App developed in Visual Studio Community 2019 utilizing ASP.NET, C# and HTML. I am trying to Publish the App locally so that it can be accessed by other Computer systems within the same server. I can successfully publish the static data (images, boxes, headings, titles, etc.) but the DataGrid on my web page does not displays any data.
I connected the data via connectionString to SSMS which works perfectly via IIS Express, if I run the application by opening Visual Studio. I am looking for a way where I don't require to open and Run the application and all computers within the same server can access it directly.

You can try using SQL Server (User name/password) authentication in connection string instead of Windows Authentication if not already done.
Also you can add the 'IIS APPPOOL\DefaultAppPool' user as a database user in your SQL instance, then providing the proper 'User Mappings' to the databases you need the DefaultAppPool user to access.

Related

Blazor server app running directly via exe not showing https localhost in cmd window & SQL data access not working. Works fine in VS debugging mode

I have a Blazor server app, which is exported into some files and an exe upon publishing. In this setup, I have 2 machines. Machine A which is being used for development and is hosting the SQL server express instance.
Scenario 1:
I run the app on Machine A. I get the following screen.
Next I open chrome and open either of the 2 localhost links and the intended website loads with the data being queried from SQL server and displayed on webpage.
Everything works as intended.
Scenario 2:
With the same setup as above, since the cmd window in indicating an active web server running, I tried to open the website on my phone using the Machine A's IP. It didn't work. This is problem 1. Getting this to work on other machines.
Scenario 3:
In this scenario, I tried to run the app on machine B with the SQL server still running on machine A. They are both in the same network. Upon running the exe, I get the following:
I am now not getting the https option. Which doesn't bother me too much if it worked. When I try to run the app, I get this new line added to cmd window.
When I try to open the localhost 5000, the website loads but no data is fetched from SQL server. So i guess i am not able to access my SQL server on machine A from machine B due to some authentication issue.
I do not want to use IIS unless there is no other way. this is an internal tool so security and elegance isn't an issue. Ease of use is the most important goal. Running the exe direct is easiest for the end user.
Thanks for any suggestions.

How to setup my C# Winforms app using local SQL Server database with (or without) Windows authentication mode?

I have developed a C# Winforms app with Visual Studio 2015 which uses a SQL Server 2014 local database.
I used ado.net to connect to database there is the connection string I used:
Data source=reza\mssqlserver2014;inital catalog=storesystem;integated security=true
And it works great on my pc.
What do I need and what should I do to set it up in another computer?
Note that I login to my SQL Server 2014 with Windows authentication mode.
I have tried backing up and restoring the .mdf file to target computer. But it didn't work.
Your app is using Windows Authentication to connect to SQL Server and I suspect your development machine's SQL instance already has been setup to recognise your account.
On the target machine, add the currently logged-in Windows user as a legitimate user for the database in question under Logons.
Though you could arguably move to SQL Server Authentication, a better security model is when the application does not use a password in the first place.

Job cannot access database after installed as Windows service

I can successfully run my jobs (that need access to an Sql Server database) when I run the Quartz.NET server in dev environment (Visual studio). But when I install the project as a Windows service, I get a login failed error to the database in my job. I have also allowed my service to interact with the desktop.
What am I not setting correctly?
You should check the Windows account your service is running under. Most probably it hasn't got the privileges to connect to your SQL Server, or to access the database. Basically, you have two choices:
Configure your service to run under an account that has a corresponding login in your SQL Server instance.
Add the account as a login in your SQL Server instance.

SQL Server database is readonly error

I am trying to upgrade one of our web application from Windows Server 2003 to a new box with Windows Server 2012. The application allows us to create multiple instances of another application as virtual directories within a website. Its more like we create an instance of a web application on run time for every signup which is customer specific. Each instance consist of SQL server MDF file that it attaches to SQL server.
The problem I am having is that MDF file is from SQL 2008 and system fails to upgrade it to 2012. If I upgrade it manually then system complains that database is in readonly mode. I have already set application pool identity to Network Service account and I believe it should have sufficient rights to attach/read/write the database. I am unable to reproduce the problem on local system where I am using Windows 8 and SQL 2012. Any help would be appreciated.
Failed to update database "some.MDF" because the database is read-only.
Network service has not part in readonly database configuration.It could depend from login role.Have you check via ssms if login user has been bind to the database and if its has the right permission.
Take a look to the image below:
if not you need to setup right configuration for your customer and so on.
The only way to get it working was by allow Network Service full control permissions using NTFS folder permission dialog.

cannot access sql server after publishing site in iis7

I am created a website using visual studio 2010. On the time of the development of website I am able to access the database.. but after publishing the site using IIS7..i was unable to access the database..the exception occured during that time was "the connection is in the closed state".in IIS7 When I changed the application pool identity to localsystem, it worked.
Data base is installed in the same machine. and server is SQL SERVER 2008 R2
you can only access database with sql authentication after publishing it.
In IIS7 the application pool by default runs under the IIS AppPool\[Application Pool Name]
That means, if your app pool is called "MyWebSite", then you must give the following user permissions to use your database: IIS AppPool\MyWebSite
It won't be in any list, so you'll have to type it as above when adding it.
I suggest making it database owner if you're in doubt about which permissions to give it. If it works, you can always refine the permissions later

Categories

Resources