Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Asp.net Mvc 3 connection string issue
- <connectionStrings>
- <add name="ApplicationServices" connectionString="Data Source=d5d3955e-1183-4e10-8892-9f9d005af0a8.sqlserver.sequelizer.com;Initial Catalog=dbd5d3955e11834e1088929f9d005af0a8;Persist Security Info=True;User ID=juydqjglrdwrhgsr;Password=***********" providerName="System.Data.SqlClient" />
- <add name="TraxzDBEntities" connectionString="metadata=res://*/Models.DBModel.csdl|res://*/Models.DBModel.ssdl|res://*/Models.DBModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=d5d3955e-1183-4e10-8892-9f9d005af0a8.sqlserver.sequelizer.com;Initial Catalog=dbd5d3955e11834e1088929f9d005af0a8;Persist Security Info=True;User ID=juydqjglrdwrhgsr;Password=***********"" providerName="System.Data.EntityClient" />
- </connectionStrings>
- Login failed for user 'juydqjglrdwrhgsr'.
- Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
- Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'juydqjglrdwrhgsr'.
- Source Error:
- Line 32: <li>@Html.ActionLink("Home", "Index", "Home")</li>
- Line 33: @{
- Line 34: if(User.IsInRole("Admin"))
- Line 35: {
- Line 36: <li>@Html.ActionLink("Admin Controls", "Index", "Admin")</li>
- Source File: c:UsersAdministratorDocumentsVisual Studio 2010ProjectsTraxzTraxzViewsShared_Layout.cshtml Line: 34
- Stack Trace:
- [SqlException (0x80131904): Login failed for user 'juydqjglrdwrhgsr'.]
- System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +5064474
- System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +234
- System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2275
- System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +35
- System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +183
- System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +239
- System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +195
- System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +232
- System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +185
- System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +33
- System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +524
- System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
- System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +479
- System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108
- System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
- System.Data.SqlClient.SqlConnection.Open() +125
- System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +95
- System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +206
- System.Web.Security.SqlRoleProvider.GetRolesForUser(String username) +847
- WebMatrix.WebData.SimpleRoleProvider.GetRolesForUser(String username) +58
- System.Web.Security.RolePrincipal.IsInRole(String role) +182
- ASP._Page_Views_Shared__Layout_cshtml.Execute() in c:UsersAdministratorDocumentsVisual Studio 2010ProjectsTraxzTraxzViewsShared_Layout.cshtml:34
- System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +272
- System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81
- System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +187
- System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer) +52
- System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +203
- System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +42
- System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, HelperResult content) +45
- System.Web.WebPages.WebPageBase.Write(HelperResult result) +48
- System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +178
- System.Web.WebPages.WebPageBase.PopContext() +338
- System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +196
- System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220
- System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
- System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +303
- System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
- System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23
- System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
- System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19
- System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
- System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
- System.Web.Mvc.Controller.ExecuteCore() +116
- System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
- System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
- System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
- System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
- System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
- System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
- System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
- System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
- System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
- System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
- System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
- System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8963149
- System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
- If you take advantage of the Sequelizer MySQL and MS SQL Server add-ons, SQLSERVER_CONNECTION_STRING and SQLSERVER_URI settings will be injected into your application appSettings. SQLSERVER_CONNECTION_STRING_ALIAS will also be inserted if you add an alias. Further, the connection string will be placed in the connectionStrings element with name set to the alias if one is specified.
- The uri is of the following format: sqlserver://username:password@hostname/databasename. If you want, you can create your own connection string (if, for example, you need a custom one for Entity Framework). Here's an example of building a standard connection string:
- var uriString = ConfigurationManager.AppSettings["SQLSERVER_URI"];
- var uri = new Uri(uriString);
- var connectionString = new SqlConnectionStringBuilder
- {
- DataSource = uri.Host,
- InitialCatalog = uri.AbsolutePath.Trim('/'),
- UserID = uri.UserInfo.Split(':').First(),
- Password = uri.UserInfo.Split(':').Last(),
- }.ConnectionString;
- <add name="TraxzDBEntities" connectionString="metadata=res://*/Models.DBModel.csdl|res://*/Models.DBModel.ssdl|res://*/Models.DBModel.msl;
 provider=System.Data.SqlClient;
 provider connection string="
 Data Source=YOURPROVIDERDATASOURCE;
 User ID=YourUserName; 
 Password=YourPassword;
 Initial Catalog=YourCatalog;
 Persist Security Info=True;
 MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
- string baseConnectionString = ConfigurationManager.ConnectionStrings["TraxzDBEntities"].ConnectionString;
- EntityConnectionStringBuilder entityBuilder = new EntityConnectionStringBuilder();
- entityBuilder.Provider = "System.Data.SqlClient";
- entityBuilder.ProviderConnectionString = baseConnectionString;
- entityBuilder.Metadata = @"res://*/";
- return entityBuilder.ToString();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement