asp.net mvc - SQL Server Express database file auto-creation error in MVC 4 - But i DON'T want to use SQL Server Express -
i've deployed new application in asp.net mvc 4. use sql server 2008 r2 (not sql express).
it worked first 10 minutes, did little change in code , re-deployed it.
now, whenever try access page uses simplemembership, error:
a network-related or instance-specific error occurred while establishing connection sql server. server not found or not accessible. verify instance name correct , sql server configured allow remote connections. (provider: sql network interfaces, error: 26 - error locating server/instance specified)
description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code.
sqlexpress database file auto-creation error:
connection string specifies local sql server express instance using database location within application's app_data directory. provider attempted automatically create application services database because provider determined database not exist. following configuration requirements necessary check existence of application services database , automatically create application services database:
but, not use sql server express. in web.config
i've set connection strings follows:
<add name="applicationservices" connectionstring="server=myserver;database=mydb;user id=myuserid;password=mypwd;" providername="system.data.sqlclient" /> <add name="applicationservices" connectionstring="server=myserver;database=mydb;user id=myuserid;password=mypwd;" providername="system.data.sqlclient" />
why keep trying create sql server express database?
when encountered error, turned out simple. figured out in _layout.cshtml referencing user.isinrole("role")
after request.isauthenticated
. code looked @if (request.isauthenticated && user.isinrole("role"))
. if wasn't signed in home page render since not traverse isinrole()
call (which requires simple membership initialized, otherwise error mention here. needed ensure each , every controller uses view extends _layout file , have unauthenticated users, needs have [initializesimplemembership]
. or 1 of various ways initialize simple membership.
so
namespace projectname.controllers { [initializesimplemembership] public class homecontroller : controller { ...
also, ctrl + f5 start application , use "rebuild solution" after. when refreshed page wasn't root home page, error until call root home page. @ point, start working again.
hopefully or someone. banged head @ least hour or two.
Comments
Post a Comment