Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > BOOK: Beginning ASP.NET Web Pages with WebMatrix
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET Web Pages with WebMatrix
This is the forum to discuss the Wrox book Beginning ASP.NET Web Pages with WebMatrix by Mike Brind, Imar Spaanjaars ; ISBN: 978-1-1180-5048-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET Web Pages with WebMatrix section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 19th, 2014, 03:33 PM
Authorized User
Points: 313, Level: 6
Points: 313, Level: 6 Points: 313, Level: 6 Points: 313, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
Default What Do _Appstart.cshtml and Web.config Have in Common?

I am trying to push a WebMatrix application out to a DEV section of a ASP.Net development environmnet (DEV/INT/PROD). I'm now using Visual Studio 2010, but initially started using WebMatrix.

I initially had issues with Web.config , but now _Appstart.cshtml is generating errors in the DEV environment.

My Web.config connectionStrings code...

Code:
 <connectionStrings>
    <add name="Development " connectionString="Data Source=ROPFDN811Q\FDNDEV15;Initial Catalog=respir;User ID=respir-admin;Password=respir-admin" providerName="System.Data.SqlClient" />
 </connectionStrings>
At first the DEV environment puked on my Web.config file, because Data Source=ROPFDN811Q\FDNDEV15 was not known but has recently been provided.

Now, DEV is puking on _Appstart.cshtml on the line below telling me connection string "respir" was not found...
Code:
WebSecurity.InitializeDatabaseConnection("respir", "UserProfile", "UserId", "UserName", autoCreateTables: true);
It's obvious there are a few things common between both these files, but it's still puzzling. I'm thinking maybe I should use ROPFDN811Q or the instance FDNDEV15 or both?

Are UserProfile, UserId and UserName generic placeholders or do they actually have to be defined? I'm assuming the latter, but that is not entirely clear to me.

Sorry if this seems rather basic, but communication with "middleware" is obfuscated where I work.

Please help!

JJ

Last edited by jpjamie; November 19th, 2014 at 03:36 PM.
Reply With Quote
  #2 (permalink)  
Old November 19th, 2014, 05:35 PM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,948
Thanks: 79
Thanked 1,555 Times in 1,532 Posts
Default

The first parameter of WebSecurity.InitializeDatabaseConnection is the connectionStringName which is Development, not respir, as per your web.config.

For more details about WebSecurity.InitializeDatabaseConnection, see http://msdn.microsoft.com/en-us/libr...vs.111%29.aspx

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
jpjamie (November 19th, 2014)
  #3 (permalink)  
Old November 19th, 2014, 06:42 PM
Authorized User
Points: 313, Level: 6
Points: 313, Level: 6 Points: 313, Level: 6 Points: 313, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
Default

Thanks! I'll try that tomorrow!
Reply With Quote
  #4 (permalink)  
Old November 20th, 2014, 04:35 PM
Authorized User
Points: 313, Level: 6
Points: 313, Level: 6 Points: 313, Level: 6 Points: 313, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
Default

First of all thank you very much for your help, as I am slowly seeing more and more light within this tunnel.

Today I discovered page 307 in Chapter 12 to be very helpful!

Here is my current connectionStrings code from my Web.config file...

Code:
 <connectionStrings>
    <add name="Development " connectionString="Data Source=ROPFDN811Q\FDNDEV15;Initial Catalog=respir;User ID=respir-admin;Password=respir-admin" providerName="System.Data.SqlClient" />
 </connectionStrings>
From chapter 12 page 307, I realize there are five arguments in WebSecurity.InitializeDatabaseConnection and they are (using your example schema): database name, table name, UserId and E-mail."

The final column indicates whether or not the table and columns should be
created automatically which I have set to false. I set this to false because I am within a very large institution with business rules and I doubt they would want anything done without permissions.

Here is my _Appstart.cshtml file....

Code:
@{
   
WebSecurity.InitializeDatabaseConnection("Development", "respir", "respir-admin", "respir-admin", autoCreateTables: false);
}
So does this code look correct?

JJ

Last edited by jpjamie; November 20th, 2014 at 04:53 PM.
Reply With Quote
  #5 (permalink)  
Old November 21st, 2014, 04:45 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,948
Thanks: 79
Thanked 1,555 Times in 1,532 Posts
Default

Hard to say as I don't know what your names like respir and respit-admin are referring to. Take another look at the help file I linked to and see if you're passing the right data.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #6 (permalink)  
Old November 21st, 2014, 06:21 PM
Authorized User
Points: 313, Level: 6
Points: 313, Level: 6 Points: 313, Level: 6 Points: 313, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
Default

Quote:
Originally Posted by Imar View Post
Hard to say as I don't know what your names like respir and respit-admin are referring to. Take another look at the help file I linked to and see if you're passing the right data.

Imar
They are referring to two database columns User Id and Password
Reply With Quote
  #7 (permalink)  
Old November 22nd, 2014, 09:43 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,948
Thanks: 79
Thanked 1,555 Times in 1,532 Posts
Default

I don't think they are. They are enclosed in quotes and thus taken as literal values.

Cheers.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #8 (permalink)  
Old December 5th, 2014, 06:32 PM
Authorized User
Points: 313, Level: 6
Points: 313, Level: 6 Points: 313, Level: 6 Points: 313, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
Default Slow Progress

Since my last posting above, I've been able to get my web app running at work on the development part of a dev/int/prod server environment. By "running," I mean the *.cshtml pages appear as they should (jQuery runs) however, no database connection therefore no joy.

All pages accessing the database generate an error, for now I can deal with that.
I moved my app from WebMatrix 3.0 to Visual Studio 2010, without any issues. I've (required) downloaded and install MVC 4.0 (which is where I'm eventually heading...and THIS is hard? ) as well as IIS, which plays a part in my question.

While my app runs fine locally opened from within Visual Studio 2010, any file opened from IIS (http://localhost/*.*) shows my images but also razor code. Is this associated with the "~" tilde in the rootpath so my CSS files and jquery files are not being found?

I've been told, if things run locally on IIS, they'll run when pushed to development.

So when I run my app on these three servers:
  1. VS 2010 locally runs my code just fine from within VS.
  2. IIS shows my code and generally makes a mess of things.
  3. My dotnetdev (development) server displays everything properly and runs jQuery, but doesn't like my database.

I realize my main issue is the database connection (probably a connectionstring issue) on the development environment, but why the different "views" on those servers? Can one of you point me in the right direction for answers?

(part time developer only)

Thanks!

JJ


I could get this running with a private account on GoDaddy without any of this mess!

Last edited by jpjamie; December 5th, 2014 at 06:47 PM.
Reply With Quote
  #9 (permalink)  
Old December 6th, 2014, 03:20 AM
Wrox Author
Points: 412, Level: 7
Points: 412, Level: 7 Points: 412, Level: 7 Points: 412, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2011
Posts: 57
Thanks: 1
Thanked 19 Times in 19 Posts
Default

Open your app within WebMatrix and click the Site tab (bottom left corner). Click settings and make sure that the selected .NET framework is 4, Integrated pipeline.
Reply With Quote
The Following User Says Thank You to Mike Brind For This Useful Post:
jpjamie (December 6th, 2014)
  #10 (permalink)  
Old December 6th, 2014, 02:24 PM
Authorized User
Points: 313, Level: 6
Points: 313, Level: 6 Points: 313, Level: 6 Points: 313, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
Default

Thanks for your time Mike!
I also realize your website has lots of superb information!

I'm making the transition from (ColdFusion developer since Allaire) WebMatrix to ASP.NET 4.0 MVC

As you suggested, I just checked and .NET 4 (Integrated) was and is selected.

I watched the (within WebMatrix 3.00 Help) video in Help: Files Workspace/PluralSight/Deployment/Deployment basics.
While the video helps for FTP and web deployment, it doesn't specifically address my deployment situation.
The video does mention connectionString, which might be of help if it generates that string for me.

My main issue is connecting to the database in a corporate (dev/int/prod) Intranet development environment.
Once I get that figured out the server issue is not as important.

Displayed in the CODE section below is my current connectionString.
For security reasons, some names where changed but the basic structure/naming integrity was maintained.

Code:
<connectionStrings>
<add name="Development" connectionString="Data Source=ROPDDN811Q\FDNDEV15;Initial Catalog=anes;User ID=anes-admin;Password=anes-admin" providerName="System.Data.SqlClient" />
</connectionStrings>
All pages on the development server environment (jQuery and CSS all link properly) run perfectly except those with a database connection or rely on the database for CRUD.
As a result, I am sure the connection string or connecting to the database is the problem.

A programmer assigned my local database file CCF.sdf the Data Source ROPDDN811Q along with the instance FDNDEV15 as shown in the connectionString above.


JJ

Last edited by jpjamie; December 6th, 2014 at 03:26 PM.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
System.web.providers error in web.config vykintas ASP.NET 4.5 General Discussion 0 April 12th, 2013 07:14 AM
App.Config and Web.Config conflict John.Burke ASP.NET 2.0 Professional 5 March 9th, 2010 10:51 AM
Fix for Web.config Error in ...\Chapter01\LINQforBinding Web Sites rogerj BOOK: Professional ADO.NET 3.5 with LINQ and the Entity Framework ISBN: 978-0-470-22988-0 0 February 18th, 2009 12:59 PM
web.config vs. app.config darlo Visual Studio 2005 11 August 20th, 2008 07:23 AM
Common question, not so common answer? flyin ADO.NET 5 March 24th, 2004 05:50 PM



All times are GMT -4. The time now is 01:15 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.