OAuth2, Azure, Asp.Net MVC5 Default template, cannot access db - asp.net

In Asp.Net MVC5, I'm using the default template
I've set customer errors of in web.config. I'm trying to connect to google and facebook. When I deploy to azure, i get the following... I've not done anything that I'm aware of locally to prepare the DB. Although I do have sql express installed for other reasons.
error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.

If I recall correctly when deploying to azure you need to specify a connection string for your project to connect to. In Azure you cant use the DefaultConnection string as it designed only to work locally

Related

ASP.NET Core - Application not connecting to database after publishing

I created a simple ASP.Net Core application with user authentication (so all the Entity Framework has been preloaded into the web app template). It is connecting to my database with the connectionString that is located in my appsettings.json file, with "data source = {computerName}\\{serverName}" setup.
The database instance and Visual Studio are located on the same machine. This works fine in returning data to the web api while within development and debugging mode. When I publish it and try to go to the site from a domain name it does allow me to view the webpages that are not needing database connection but the rest that need data from the database returns pages like this:
Error.
An error occurred while processing your request.
Development Mode
Swapping to Development environment will display more detailed information about the error that occurred.
Development environment should not be enabled in deployed
applications, as it can result in sensitive information from
exceptions being displayed to end users. For local debugging,
development environment can be enabled by setting the
ASPNETCORE_ENVIRONMENT environment variable to Development, and
restarting the application.
I have tried to change the Environment Variables for ASPNETCORE_ENVIRONMENT from Development to Production to no success.
I have tried adding appsettings.Production.json to publishOptions in my project.json file, even though there is no file appsettings.Production.json, and this did not help. dotnet publish
Adding the evironment variable in the web.config file did not work Deployment
I need help getting the published web api to connect to my SQL Server database from outside the development Visual Studio setup.
The last thing I can think of is that maybe I am incorrect in how I understand the connection string. If the web api uses the connection string to connect to the database from the server-side then it should work just fine like it does when in development calling to http://localhost:port# since it's all on the same machine. But, if the database string needs to be based on a client-side call then it would have to be with domain names and IP addresses.
Can someone tell me which one it is?
The only thing else that comes to mind is that there is something I am not doing, and need to do, inside of IIS Manager. I see connect string there as well but unsure what that is for our does since the connection string is inside the application. Also maybe I am suppose to give the app some kind of authorization to communicate with the database server even though they are on the same machine???
After much research, finally googling "how to deploy a web api in iis" I was able to learn from Host ASP.NET Web API in IIS using Visual Studio Publish that I needed to add the security entity BUILTIN\IIS_IUSRS. Then placing a mapping to my database tables and giving db_datareader (and possibly db_datawriter) for the database to the IUSER to allow access from my self hosted IIS web api. This from the above mentioned link with the part stating
Accessing Database under IIS APPPOOL\ASP.NET v4.0
As we are using ASP.NET v4.0 App Pool make sure IIS APPPOOL\ASP.NET v4.0 is added to your Database Server -> Security -> Logins.

umbraco deployment in azure websites and sql azure

I am new to umbraco and I tried to create an application using it . I created an empty mvc application in visual studio 2013 and add UmbracoCms nuget package( Version 7.1.4). When I ran the app it asked for installation and is successfully installed in a local SQL CE database.
I added the required Controller ( inheriting SurfaceController) and the model required in my partial view . The project compiled and the page worked fine.
Now I need to deploy this site to Microsoft azurewebsites. When I publish the site from visual studio publish option(I specify the website name, sql azure db name and credentials ) to azure the whole publish process gets successfully done. When I browse the site it goes the page that reads "Looks like there's still work to do" and when I click the "Set up your new website" button it goes to the login page "http://XXXXX.azurewebsites.net/umbraco#/login/false". I don't have the credentials since this is a new deployment and I also tried the local one but it did not work either. I believe that the sql azure db is not setup for this. I was of the opinion that when I run the site it willl take me to the installation page . But it did not.
Any help on this would be really appreciated.
Thanks.
Since you installed umbraco locally with SQL CE the web.config gets updated with the current version (its an appSetting) and a connection string. When you then deploy that to Azure it will look like the site is already setup.
Now, I don't know if you included the SQL CE database in your deployment package because with that the site would work (with the credentials you choose locally). But ideally you'd want to set it up with a SQL azure database. To do this you can "reset" the umbracoDbDsn connection string in web.config and remove the version in appSettings. Doing that will make Umbraco start the installation when deployed to azure.
In the umbraco installer you simply choose Customize to get the dialog that always you to enter a connection string for SQL azure.

Aspnet conguration connection test fail after correct configuration

I am building web form using VS2012Express edition. I am trying to implement SqlMembership provider. i did the congfiguration and all the neccessary objects are install.i can see the aspnetdb on my db server with all the objects.But when i try to create new user by goin to Project and ASPNET Configuration then Provider tab. i click the test connect and receive this error.Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider.
I have done what this error message is telling and have look at several samples on MSDN site. Could the problem be because i have both VS2010 Profession and VS2012 Express installed on my machine or am doing something wrong somewhere?
here is my webconfig.

ASP.NET: Can't connect to SQL Server database after uploading to server

I'm trying to upload my asp.net site to my HostGator windows server. I'm having a problem connecting to the SQL Server database in my App_Data folder. It's giving me the error:
Login failed for user 'PSS004\IWPD_353([UserName])'.
I use Windows Authentication in Visual Studio 2010 to access the database and view the site just fine locally. Is that causing a problem? If so how do I set up a user/pass to use when accessing the database file once it's on my hosting server?
If any further information is needed that I left out just let me know.
Thanks!
When you run the code from your webserver, its most likely using a network service account (and hence windows auth wont work). Add a user account to sql server and change the connection string to use sql auth instead and that should fix it

Publishing ASP.NET site - No login database?

I have a very simple app on my local machine that uses the ASP.NET membership provider. This works fine on my local machine.
I have published the app to our web server, and I need to know the specifics of setting up the application for asp.net membership to work.
I have a basic understanding that it uses an MDF file and somehow connects to a SQL database (SQLEXPRESS I assume on my local machine) which holds the user/role information.
I keep getting an error that it cannot connect to a SQL database when running the published application on the web server.
I wish to use a SQL server on a different machine (SQL69) than my web server (WEB69)
I have created a new connection string, but how do I tell ASP.NET to use it instead of the "LocalSqlServer" connection string that is created by default?
Can someone explain what is required to me?
Thanks for any help you can offer.
Use the ASP.NET SQL Server Registration Tool without any parameters to set up the SQL Server membership on your local machine. This will also update your config file:
http://msdn.microsoft.com/en-us/library/ms229862%28VS.80%29.aspx
You need to set up SQL Server DB membership on your local machine first. After you have this working, you can simply script the entire DB for your production environment. For this, you can use the Database Publishing Wizard in VS.
You can view a sample config file here:
http://www.codersbarn.com/post/2008/02/24/ASPNET-20-Guest-Book-Admin-Part-II.aspx

Resources