ASPNET authenticate fail with IIS - asp.net-mvc

I have develop MVC Web Application
I use ASP.Net authenticate to implement my login form
The problem is that i cannot deploy it to server.
In the first i use ASPNetDB.mdf which is a file store in AppData forlder
After that I change to store ASPNETDB as a database in SQlServer and also update the connectionstring to new database
In the development environment both of them work well
But when I deploy to IIS, I cannot login, it show me following error :
"Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed."
Here is my connection string:
<connectionStrings>
<add name="ApplicationServices"
connectionString="Data Source=.\PHDatabase; Initial Catalog=aspnetdb;User ID=sa;Password=****" />
</connectionStrings>
I try to google a lot but until now, there is no result
Please help me to solve the problem
Regard

Try replacing machine name instead of a "."
Data Source=machinename\PHDatabase; Initial Catalog=aspnetdb;User ID=sa;Password=****
The other possibility is if you are using certain wizards like Linq2Sql etc., they might keep the connection string inside the code. Check for them as well..

In development environment, when you are using Attached Database file from App_Data folder with SQL Express, you should use the following connectionstring
<add name="YourConnectionStringName"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;
AttachDBFilename=|DataDirectory|\YourDatabase.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
But, when you testing or deploying with Database on the SQL Server, you should make use of following type of connectionstring
<add name="YourConnectionStringName"
connectionString="Data Source=db.YourhostedResourceName.com;
Initial Catalog=YourDbName;User ID=yourusername;Password='yourpassword';"
providerName="System.Data.SqlClient" />

Related

In ASP.Net Database First Approach , Why can't i see ASPNet tables (ASPNetRoles, ASPNet users etc)

I have created ASP.NET MVC Web application but I cannot see ASPNet tables created in database.
Tried so far:
I checked in web-config file if choosing the authentication at the time of creation of project makes this difference and and found <authentication mode="None" /> in web-config. So I thought may be because i might have chosen No Authentication in the beginning that is why I dont have those tables in database. Then I have changed manually in web-config file to <authentication mode="Forms" /> to create individual user authentication.
However even after updating the authentication mode to forms it is still not showing ASPNet tables in the database.
I have noticed that ASP.Net Identity tables are created in localDb and I have created my another database with tables for my application. Now I want to see ASPNet Identity tables from local db in my own created database.
In the web-config file i have updated the data source with the data source of other connection string of my database .
<add name="DefaultConnection" connectionString="Data Source=SQLCLUSTER;initial catalog=TimeSheet;integrated security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
<add name="TimeSheetEntities" connectionString="metadata=res://*/TimeSheet.csdl|res://*/TimeSheet.ssdl|res://*/TimeSheet.msl;provider=System.Data.SqlClient;provider connection string="data source=SQLCLUSTER;initial catalog=TimeSheet;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" /></connectionStrings> ```
After running the application in debug mode I still can't see the ASPNet tables in my own database.
How can I get those tables?
What did I miss which is cause of this issue?
Any clarification would be much appreciated as I am newbie and learning Authentication and Authorisation at this point.

Deployed application doesn't work after changes connectionString MVC ASP.NET

I made application using DataBase First approach with oracle (in this way https://www.youtube.com/watch?v=tk_EDjTzZCE so I used Entity Wizard)
I deployed my application on http://www.smarterasp.net/
Everything works fine.
But I decided to change connectionString in webconfig. Because I wanted to use database from another server. New Database has literaly same structure as old but still doesn't work.
Also I tried to change connectionString before deploy. I compiled the application and when I run - receives an error: ORA-00942: table or view does not exist
If I add database again using Entity Wizard (check youtube link above) then everything works fine. How can avoid this? Maybe my connectionString is wrong?
<connectionStrings>
<add name="DbEntities" connectionString="metadata=res://*/DAL.DbModel.csdl|res://*/DAL.DbModel.ssdl|res://*/DAL.DbModel.msl;provider=Oracle.ManagedDataAccess.Client;provider connection string="DATA SOURCE=some-link.com:1521/ORCLBK;PASSWORD=some_password;USER ID=some_login"" providerName="System.Data.EntityClient" />
</connectionStrings>

Mvc Online website has intermittent login request

We have deployed a website online and logged in as a user, we see a request to login (intermittently and on random actions). This seems to happen when the action needs to be authorized according to the users role. It appears as if the system thinks that the user does not have the required role. This happens even when the user has the role required to access the action.
We cannot recreate this problem offline, even connecting to the online database with Visual Studio does not recreate the problem. Since this login request is also intermittent there is no consistent way to recreate the problem.
This is how we have structured sections of the connection strings in our web.config file:
<add name="DefaultConnection" connectionString="Data Source=xxxxxx,1444;Database=xxxxxx;Integrated Security=False;User Id=xxxxxxx;Password=xxxxxxxxxxxxxxx;" providerName="System.Data.SqlClient" />
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=xxxxxxxxx,1444;Database=xxxxxx;Integrated Security=False;User Id=xxxxxxx;Password=xxxxxxx;" providerName="System.Data.SqlClient" />
Removing the LocalSqlServer section generates the following intermittent Exception:
This error also cannot be recreated offline connecting to the online database

How to modify the internet application for mvc projcect in Visual Studio 2012 code and connect with database?

I am beginner in ASP.NET MVC. I have been trying to create a web application in ASP.NET MVC 4 by using Visual Studio 2012. I started with internet application and open with default template that has registration, login, home etc pages. I have tried to modify the code available for the registration form as I want and connect with SQL Server database, but it does not work and also only connected with local database it is not connected with my database table I have created in SQL Server. What will I do? Thank you for your help
Have you changed your default connection string in your web.config to point your sql server?
The default connection string will be like this
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-yourproj-timestamp;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-yourproj-timestamp.mdf" providerName="System.Data.SqlClient" />
In your case you should have changed as follows,
<add name="DefaultConnection" connectionString="Data Source=localhost;Initial Catalog=aspnet-yourproj-timestamp;User Id = xxx;Password = xxxxxx" providerName="System.Data.SqlClient" />

issue while connecting to local database for MVC3 + EF app

I am new to implementing an application on MVC3 + EntityFramework. Can somebody suggest as what approach to apply to access my tables and views from my existing local database (Sql server 2008). I could see some default files created under App_data folder which i dont want.
Cheers,
Chris
You could change the connection string in your web.config to point to your real SQL database:
<connectionStrings>
<add name="DefaultConnection" connectionString="Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;" providerName="System.Data.SqlClient" />
</connectionStrings>

Resources