ASP .Net Web App not publishing .cs files and Database - asp.net

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.

Related

How to open the starting file of an ASP.NET Core Razor Pages app?

I have a basic question so apologies in advanced but I have been googling for hours and not been able to find the answer. I made an ASP.NET Core Razor Pages app and deployed it to a folder (which is in a network, it's basically our staging environment) and now need to know how to access the index page in the URL. I followed this doc on how to publish the app into a folder: https://learn.microsoft.com/en-us/dotnet/core/deploying/deploy-with-vs?tabs=vs156 (I chose the Self-contained deployment without third-party dependencies option) but now how do I access the index file?
For example if this is the URL: https://testing.com/FolderName
And the app is in the 'FolderName' folder what do I need to follow up next in the URL to open the app? Inside the FolderName folder there is wwwroot folder, appsettings.Development, appsettings, the .exe, a .pdb, and a web.config. So how do I access the app in the web? I also tried copy/pasting the files and navigating to index.cshtml but didn't work either.
Any help would be greatly appreciated. Thanks guys.
Razor Pages are not routed based on the file system (like PHP).
You start the Web server (by opening the exe) and navigate to the URL where the Web server tells you it's serving the app (in the terminal you should see a line that says "Listening on https://your_url:port...").
The index should be the first thing you see when you navigate there.

Where does IIS look for files

Can anyone explain, please, exactly how .net works. I create a web site in Visual Studio and publish it to a local server to a folder at
D:\WebSites\Project1
I create a web site in IIS and provide the address of the folder containing the files for the web site. When I publish the site, using 'fixed naming and single page assemblies', all the .aspx files go in the folder on the D drive and a dll for each page goes in the bin folder inside that folder.
I would assume that when someone wants to view a page in their browser, IIS retrieves the file(s) required from the folder specified, they get processed and turned into html and sent to the browser.
Recently when someone clicked a button on a page that calls a web service - a file not found error was reported. Apparently
C:\Temp\bx5tn2js.dll
could not be found. The thing is - why did IIS decide to look in C:\Temp for a file?
And, in the error message was a load of references to xml serialization. What is being serialized?
This file looks like the compile files that asp.net generates on compile.
This folder can be setup on web.config on compilation session with the
tempDirectory="C:\Temp"
If you do not have set this option asp.net is use a default folder that is usually inside the asp.net directory, inside the windows folder. But if you have set this, and this folder did not have the correct permissions, then asp.net fails to compile the project, and you can get a message like that.

asp.net unpublishing

I published my web application to a folder , after I hosted that folder on a server,but my project codes are broken.Now I will republish(unpublisch) my application from the publish folder. I will see my aspx page's .cs codes.how can I see
you have no choice to unpublish your code. While you work on the project before publish u have to take the copy of the project. while publishing ur codes are converted to dll. no way to recover ur codes from the dll.

asp.net manual copy to server

So I just got a site hosted at hostasp.net. In VS I'm working with a web site not a web application. In the control panel on the host under my site I have folders (data, logs, wwwroot). My current project only has 1 javascript file, 1 aspx page, and a web.config. I placed Default.aspx & web.config directly under wwwroot. In VS my javascript file is in a subfolder named Scripts so I created this subfolder on the host site and placed my javascript file in there.
When I access my site I get "Server Error in '/' Application." error. What am I messing up here?
Also if I have a code behind file, where do I put that? Should it be compiled somehow? When I built the VS project it doesn't give me any dll for it or anything. Right now I don't have anything in the code behind but just wondering for later if I do.
If you are using Visual Studio:
You can certainly just copy the files to your live server. Your "code behind" files will be compiled at run time.
You can Publish a Web Site or Web application so you have the option to pre-compile (to dll) all your code (and will be in /bin folder).
If you want to remove the "guessing" of which files you need to "push" to your live server. You can publish to your local file system or directly to FTP. VS will pre-compile your Web Site or Web Application, and "collect" all the necessary files that make up your web site/application and save it in the folder/FTP site you designate.
If you chose to publish to file system, then all you have to do is copy/ftp (whatever) to your live site. You might ask why even publish to local (first) only to FTP it anyway? So you can get fully acquainted with how all of this works - the different publish options, etc. locally (which is essentially the exact structure of your production site).
Publish Web Site (VS):
Publish Web Application (VS):
The only time this may not work is when your host doesn't have the "bits" that you might have. E.g. not all hosts may have the latest/greatest from Microsoft, like say, Web API and all the assemblies it entails.
But again, the tooling can help with Add Deployable Dependencies...which does and when you publish, the dependencies are all "bin deployed" (meaning they'll be in the /bin folder):
Hth...

MSBuild error while compiling ASP.NET website

I get the following error when I try to compile an asp.net site using a custom build script.
error ASPCONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
Although the description is in detail I do not understand what it means exactly. I have not configured IIS to host this website and I don't think I will be able to as I am running Vista Home Basic version. So the website cannot be built using custom scripts?Please reply as I want to test this feature.
I had this SAME EXACT problem and finally discovered a rogue Web.config was placed in my obj folder ... do yourself a favor and do a search in all the sub-directories for a web.config file. I deleted it and all was back to normal.
The rogue web.config file in the obj folder is most likely to be caused when you do a Publish Web Site. So just clean it up after you've done the publish.
if this happens after the virtual-directory is already created do the following:
right-click on web.config
properties
Build Action: Content
Copy to Output directory: Do not copy
if transformed (apply to all configurations)
properties
Build Action: None
Copy to Output directory: Do not copy
It is likely that your web.config file is placed in a directory that is not the root of the application. On most versions of IIS, you can convert any folder on your web site to an application root:
Open IIS and navigate to the appropriate folder
Right-click on the folder, select properties
Under Application Settings, and beside Application name, click Create
Apply and close
If this does not fix your problem, there may be another configuration error, either with IIS or your application.
In IIS, go to the folder that the app runs under, right click it, go to properties.
On the Directory tab, look for "Application settings". Click the create button.

Resources