Location of DB file in Visual Studio 2012 MVC - asp.net

I have been trying to learn ASP.NET MVC, and have been following this tutorial.
It is working fine. However, it is mentioned in the tutorial that if I include "AttachDBFilename=|DataDirectory|\ContosoUniversity1.mdf"
In the connection string, my database file will show up inside App_Data Folder.
However, I cannot find the database file. It is created, however does not show up inside the folder.
Where is it located (in general) ?

Try clicking the "Show All Files" button in the Solution Explorer in Visual Studio. I believe the file gets generated, but it's not included in the Web Application project automatically.
or right click on the App_Data Folder and then click on open in file explorer you will find file there but mostly the file is hidden.

Related

ASP .Net Web App not publishing .cs files and Database

I have a web portal app. I built it in Asp .Net. The app is now ready but when I try to publish it using Visual Studio, I only get the .aspx and .css files. It does not include the .cs files that have all the backend code and functionality, and it does not include the database either. The method I used for publishing the app was:
Right Click my project -> Click on Publish -> Select IIS,FTP,etc -> Select File System and provide Target Path -> Click Save.
It published the app at that targeted location. But, when I open that folder, I can only see the .aspx and .css files and no .cs files, as you can see in the following screenshot.
https://drive.google.com/file/d/15pecp8tbamjlWCm4rfV6M_zeW7zdUUB9/view?usp=sharing
At first, I thought maybe this is how it publishes the app, as this is the first time that I have tried to publish a web app. Therefore, I loaded it to IIS as it is, and tried to browse it. When I browse it, it loads the first page, that is a login page, correctly. But when I enter user credentials and try to login, it provides me with following error:
https://drive.google.com/file/d/1TIC0gE1tFpcne4bXaSsEVm8yiOPnIyOt/view?usp=sharing
I have underlined the lines by which I got the idea that the error is related to database and .cs files.
Please, if anyone can help me about this, it will be really appreciated. I have a deadline and I dont have any idea that how can I solve this problem.
Thanks.
When you publish your web application the visual studio compiles all your your cs/vb/class code into binary files (dll), this dll files can be found in your site bin folder, so you can't find the .cs file.
There are many causes of the network path was not found which are given:
1.Antivirus 2.Firewall 3.SQL Server Network configuration.
and please check if you have the port in the connection string "Data Source=x.x.x.x,1433".
More information about this error you can refer to this video:Resolving SQL Server Connection Errors
For a web application your .cs files are compiled into a DLL which will be in the bin folder.
The special App_Code folder can be created and the .cs files in there will no be compiled during publish and will be compiled by IIS on demand.

How to regenerate web.config file?

I am making a asp.net mvc project. It works fine on localhost but after deploying it was causing many errors related to web.config file.
So i deleted that web.config file. Now i want my application to regenerate web.config file. How can i achieve that?
I know that there was a problem with web.config file because i replaced it with web.config file of another and it is working now but i don't want to take any risks so i would prefer file of this project only.
I believe you have a few options here:
You can add a Web.config file at any time by right clicking your Web project, clicking add new item, and selecting "Web Configuration File." Then copy the contents of your known good Web.config into this new file through Visual Studio.
You can copy the Web.config that is deployed currently to your project through the file system. Place the Web.config in the Project folder:
Then, click on the "Show all files" button in solution explorer and include your new Web.config in the project by right clicking the file and selecting "Include in project."
If you don't have any copy of the Web.config, you can create a new Web project through visual studio, and copy that Web.config as described in #2. You will most likely have to update settings like the connection string and assembly bindings.
May I also suggest using source control in the future, if that is applicable to you and your project. There are tons of free options out there like VSO/Team Services and GitHub to name a couple.

ASPNETDB.MDF file not showing up in APP_DATA

I'm taking Microsoft's walk through on MVC 2 Forms Authentication - http://msdn.microsoft.com/en-us/library/ff398049.aspx
According to the walk through, when I register a user, ASP.NET creates the ASPNETDB.MDF file and it is supposed to show up in my APP_DATA folder upon refreshing in the solution explorer. The problem is, for me it is not and I want to have a look inside so I can understand it's structure.
I can continue to run the project and login as the user I created, yet the ASPNETDB.MDF file is still not visible under the APP_DATA folder.
Am I missing something here? Any help is appreciated as always!
Cheers
Chris
Try clicking the "Show All Files" button in the Solution Explorer in Visual Studio. I believe the file gets generated, but it's not included in the Web Application project automatically.

This application is currently offline. To enable the application, remove the app_offline.htm file from the application root directory

can any body suggest me how to remove the app_offline.htm file from application root directory in asp.net web application.when i run the page it doesnt show the design of html source
Go to Visual Studio 05/08 and open the solution explorer.
In the root folder there should be a folder named "App_offline.html". Right
click on it and delete it.
Re-open Visual Studio and you should be able to browse your page.
If you cannot find app_ofline.htm file in solution explorer, use windows explorer to get to the position of the solution and delete it manually. You can do it by rigth clicking to solution and clicking on "open folder in file explorer".
Just go to the root of your web directory, it should be there. it is something that VS puts there during certain tasks.
Solution for the problem
"This application is currently offline. To enable the application, remove the app_offline.htm file from the application root directory."
Go to your IDE (Visual studio)
Go on the solution Explorar in which site error is showing
RightClick and Delete that file.
How to solve this problem, when you got this error on the web page like as following image.
Solution 1
You can delete it from your project folder like as following picture , and then you can run your web page again, it will be okay .
To when running an ASP.NET app locally & receiving 'App is offline' small yellow bad screen. To resolve one set of steps maybe:
Visual Studio Solution Explorer select the file App_offline.html
'Exclude from Project' Right click and select
F5 - Build and Debug project again
The ASP.Net runtime environment checks the root of the application on the server for an “app_offline.htm” file and if it exists then it stops processing the new requests for the application and redirects the user to the “app_offline.htm” file to notify the user about the change.
So any time following message occurs
"This application is currently offline. To enable the application,
remove the app_offline.htm file from the application root directory."
Remove the magical file “app_offline.htm” from the Home directory
Go for the root folder and search app_offline.htm. You will get the file and just delete it and restart your visual studio
And i have indicated why this app_offline.htm is created
This is a .NET 2.0 "feature"
http://weblogs.asp.net/scottgu/archive/2005/10/06/426755.aspx
http://www.codeproject.com/KB/aspnet/app_offline.aspx
"The easiest way around this is to never publish directly to your server. You shouldn't anyway... Publish to a local folder then copy the site up"
Do you use Visual Studio? http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=102778

I am working with Visual Studio 2008. Actually there is References folder missing

I am working with Visual Studio 2008. Actually there is References folder missing in its solution explorer. When I create a New web Application it has References folder but when I add new .aspx file it also adds .aspx.designer.cs file with it and its does not show master page option in add dialogue. but in the old web application it shows the master page option where master page file is already added. whats the difference between these two solutions. And how can I make it correct??
In Solution Explorer, right-click on project node. Select "Add new item" -> "Web Content Form". You will be prompted to select the appropriate master page.

Resources