Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9079207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:47:18+00:00 2026-06-16T19:47:18+00:00

I am creating a C# MVC4.5 project using entity framework with the following connection

  • 0

I am creating a C# MVC4.5 project using entity framework with the following connection string set in my Web.config:

<connectionStrings>
    <add name="Entities" 
         connectionString="metadata=res://*/PersistenceModel.csdl|res://*/PersistenceModel.ssdl|res://*/PersistenceModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\sqlexpress;initial catalog=TravPro;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" 
         providerName="System.Data.EntityClient" /> 
</connectionStrings>

I then access this string as follows:

string con = ConfigurationManager.ConnectionStrings["Entities"].ConnectionString;
WebSecurity.InitializeDatabaseConnection(con,
                                         "UserProfile", 
                                         "UserId", 
                                         "UserName", 
                                         true);

This throws an ‘Illegal characters in path’ exception:

[ArgumentException: Illegal characters in path.]
   System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional) +10631190
   System.IO.Path.Combine(String path1, String path2) +42
   WebMatrix.Data.ConfigurationManagerWrapper.GetConnection(String name, Func`2 getConfigConnection, Func`2 fileExists) +208
   WebMatrix.Data.ConfigurationManagerWrapper.GetConnection(String name) +91
   WebMatrix.Data.Database.OpenNamedConnection(String name, IConfigurationManager configurationManager) +18
   WebMatrix.Data.Database.Open(String name) +61
   WebMatrix.WebData.DatabaseConnectionInfo.Connect() +42
   WebMatrix.WebData.SimpleMembershipProvider.ConnectToDatabase() +25
   WebMatrix.WebData.SimpleMembershipProvider.CreateTablesIfNeeded() +35
   WebMatrix.WebData.WebSecurity.InitializeMembershipProvider(SimpleMembershipProvider simpleMembership, DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean createTables) +73
   WebMatrix.WebData.WebSecurity.InitializeProviders(DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +51
   WebMatrix.WebData.WebSecurity.InitializeDatabaseConnection(String connectionStringName, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +51
   TravPro.Web.Filters.SimpleMembershipInitializer..ctor() in c:\Work\trunk\TravPro\TravPro.Web\Filters\InitializeSimpleMembershipAttribute.cs:43

Can someone please assist and let me know which characters need to be escaped or how to fix this exception?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:47:19+00:00Added an answer on June 16, 2026 at 7:47 pm

    I tried it your way (@marc_s), however I still had problems, although it did lead me in the direction of the solution. I change the connectionStrings to:

    <connectionStrings>
        <add name="DefaultConnection"
             connectionString="data source=.\sqlexpress;initial catalog=TravPro;integrated security=True;MultipleActiveResultSets=True;"
             providerName="System.Data.SqlClient" />
        <add name="Entities"
             connectionString="metadata=res://*/PersistenceModel.csdl|res://*/PersistenceModel.ssdl|res://*/PersistenceModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\sqlexpress;initial catalog=TravPro;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;"
             providerName="System.Data.EntityClient" />
    </connectionStrings>
    

    And everything seems to be gravy now. I created a new project template, ran it, and saw the difference in connection string formats.

    The following is now in my InitializeSimpleMembershipAttribute.cs:

    WebSecurity.InitializeDatabaseConnection("DefaultConnection", 
                                             "UserProfile", 
                                             "UserId", 
                                             "UserName", 
                                             true);
    

    Thanks for pointing me in the right direction.
    Much love.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an asp.net mvc4 site using entity framework 5 with codefirst and
I am making an MVC4 web application using Entity Framework 5 (Database-first with generated
I am creating a web api using asp.net mvc4 and the response output is
I'm creating a web shop using MVC4 razor syntax, repository and Unit of work.
using System.Web.Security; I'm creating a resetPassword form in MVC4: using System.Web.Security; [HttpPost] [AllowAnonymous] public
Using VS2010, creating a new MVC 4 Web API project. Just wondering, can the
I've project using Entity Framework 5 Code First, WebApi, ASPNET MVC 4, Repository and
I have an MVC4 app which I've recently upgraded to Entity Framework 5 and
I'm creating an ASP.NET MVC 4 web site, and with the default project template
Using MVC4 and EF5 codefirst. Got a problem whereby when creating a new data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.