I received the below ASP.Net project. I need to understand the working of this webserver from its code. Where should I start exploring this project from I am a newbie in ASP.Net and C#. Which file among the below will contain the server listening command?
Project Structure
.cs files are the "C-Sharp" code behind files. The ones in the AppCode folder are likely relevant to the project. You should also investigate the "Default.aspx" and associated "Default.aspx.cs" file. This is the default webpage and code-behind file. This does appear to be webforms at first glance. Also, your "web.config" file will likely have server/application configuration information in it. The ".sln" file is your solution file.
That is essentially the File that you can use to open in visual studio, and it should pull in the necessary configs/files to build the project. Open the files up and start exploring.
Related
I have a fairly large solution with a mix of assemblies and ASP.NET websites (the ones without a csproj file). I'm trying to customize the build from the command line, and so I need to understand what exactly MSBuild is doing.
When MSBuild builds .sln file, I see that it creates metaproj files (which I assume are MSBuild files). However, they never seem to appear on the file system. I assume that MSBuild keeps them hidden in some way. Is there a way that I can view these files?
use the following environment variable:
set MSBuildEmitSolution=1
Some "under the hood" basics for Web Site projects that gets lost the way MS organizes their docs...
When MSBuild is executed on a .sln file it generates a .metaproj file based off of the "Project" section in the .sln file. It then executes aspnet_compiler.exe against the metaproj file.
I've worked with PHP but never C#, and I need to make 1 change to a file, and was hoping I could get some guidance, or suggested resources to learn more.
I have 1 cs controller file where I want to change the [Authorize(Roles="A")] to [Authorize(Roles="A,B")]
I made the change but nothing happens, so I've come to the conclusion that this cs file probably needs to be compiled.
The question is, is there a way to compile this one file? Or does the entire site need to be compiled?
When I open the cs files, it opens with "Visual Studio Tools For Application 2.0 2008".
Is this sufficient to make the changes?
My thinking is that one of the following needs to happen:
Scenario 1:
Open the .cs file in the appropriate compiler (of which I do not know
what it is) Compile it and copy the newly compiled file into the
appropriate folder.
Scenario 2:
Open the whole project in a compiler - of which I'm guessing the
".csproj" file to open. Compile the whole project Copy the desired
compiled file to replace the old file.
Scenario 2b:
Open the whole project in a compiler - of which I'm guessing the
".csproj" file to open. Compile the whole project Copy everything
back to the server.
Scenario 3:
The code I have is not sufficient to do the changes, and I need some
other source code.
That's all I've got, if someone can suggestion which one(s) may be on the right track, and how I may go about doing this, it would be greatly appreciated.
Thanks
The fact you are talking about a Controller would strongly suggest you are working on an ASP .NET MVC project. You will have a .sln file which is a solution file which is the master document if you will:
YourWebsiteSolution.sln
YourWebsiteProject.csproj
YourController.cs
Once you open the .sln file with Visual Studio (you need to know what version but you can get the latest here: Download VS2012 Web Express). You can the choose Build -> Build -> ReBuild Solution from the menu and that will re-compile all of your .cs and associated files into DLLs that will be in your \Solution\Project\bin\Debug folder (or Release depending on build).
When you deploy to the server you only deploy the .DLL files (in this instance). You NEVER deploy the actual .cs files as they contain the code and you don't want people peeking into them (this differs from PHP where the code is on the server).
Because you have not changed any of the views you don't need to follow this step but for a full deploy you would also copy any .cshtml or .aspx files and the usual suspects such as .css and .js etc to same folders on server as on the project.
I hope that is a good starter to get you going?
I just publish an asp.net website then i made changes in its source code i added two .aspx files and then publish it again
The question is what I need to make this changes take effect on server. Do I have to replace all files or i can just add specific file?
I'm trying to add two aspx pages to the site that already exist on the server
and want to know which file i have to add beside the ordinary aspx file to take effect on site
Thanks
This depends on how you are deploying your code. Are you using the precompile option before publishing or just publishing with pre-compilation.
If you are just publishing then you can just replace the .aspx and aspx.cs files and the site will dynamically recompile.
If you have pre-compiled it then you are probably only left with .dll files and .aspx files so you would have to deploy a new copy of the .dll file for your site and the .aspx files. MSDeploy replaces the entire site by default.
If you have only changed the aspx file and not the code behind it is enough to publish those two files and on the server. If you have changed the code behind as well you also need to publish the dll files, in that case it's probably easier to replace all of the files.
I'm still learning the basics of how VS2010 sees the world. Apparently, you can optionally "include" a file in a project. I'm a bit confused by this: If a file is version-controlled, AND the file is within the project directory, shouldn't it implicitly be "included" in the project? If not, what's the use case where a version-controlled file in the project directory should NOT be included in the project?
=== Addition ===
Based on the answers I've gotten so far, maybe I should rephrased my question: What does it mean for a file to be "included" in a project?
A project needs to know about files in order for compilation and distribution to occur. Just because you have a file that's under source-control, doesn't mean that it will be compiled if the project is unaware of it.
Also, you may want to include files as part of a distribution package. We do this quite often for our web projects that we distribute using web app gallery.
Conversely, you could have documentation or sql scripts that you version control, but do not want them to be part of the project.
EDIT: In answer to your update, what it means for a file to be included in a project is that the file is actually added to the .csproj or .vbproj file and will be used during compilation and/or distribution. VS does differentiate if the file is Content or if it needs to Compile it. This can be seen by clicking on the file in Solution Explorer and looking at the Build Action property.
No, you don't want random files that happen to be in the project directory included in source control.
We do sometimes put documentation (pdfs) or drawings/schematics in the project folder and under version control but you don't need them inside the visual studio project (especially when they are not being distributed because they are for internal use only).
Excluding the file from your project can be useful if the file is related to the project but not necessarily needed in the solution.
Example
If I need some test XML for an application that i'm writing; that is designed to normally be pulling this from a WCF service, it can be useful to keep that file in the directory for a development environment where I use IO to get the XML for testing, but I don't necessarily want it in my solution which is source controlled.
When you exclude a file from a project is no longer compiled or embedded, then when you want to include it again you can do so without having lost your settings.
If you e.g. copy a file (containing a helpful class which want to have in your project) into a folder of your project, then you will see ... nothing. You have to check the option "Show all files" of the solution explorer and the copied file can be seen, but it is still "greyed out". No you can choose the menuitem Include in project and that file will be integrated in your project and a pending change (add) for your source control is added too. Visual Studio doesn't include all files it can find in the project folder automatically to the project - and that is a good feature.
One of my colleagues explained to me a scenario in which a version-controlled file should NOT be part of the project. Here's the idea:
A developer writes some new code.
The code is experimental, and not intended to be part of the normal build.
The easiest way to exclude the file from the build is to NOT include it in the project, but still version-control it.
This way, the file can be shared with other developers, but not break the build.
Developing a silverlight page in already existing web application for previewing video files. When I create a asp.net application locally and add silverlight application on the solution it works perfectly. But while I am trying to include into already existing project it throws this error. I have not deployed into the IIS. this happens while debugging.
Check the path to your xap file in your webpage. It should be something like:
/ClientBin/my.xap
Also ensure that your xap file is actually in the ClientBin folder. In the web application Properties, choose the Silverlight Applications tab and add the silverlight project to the list.
Although probably not applicable in your case, this can also occur if you are using iis and haven't registered the correct mime type for .xap files. It should be set to application/x-silverlight-app.
This is little same with another answer, but I give my detailed solution with image of setting.
In my case, one of my aspx page will load Zip and Xap files under ClientBin Folder, normally it'll load 20 Zip/Xap files under ClientBin\,
But I found that when building/publishing the project, the Zip/Xap files are NOT output to ClientBin\, that is ClientBin folder is nearly empty.
So my solution is to let the Zip/Xap files output to ClientBin\, to do this, the setting way can see this article:
https://social.msdn.microsoft.com/Forums/silverlight/en-US/d8e2c92a-4b31-4e4b-a440-4960a8d475b4/how-to-generate-xap-file?forum=silverlightstart
Besides here is the screenshot of my setting, that is Right click at your Silverlight project > Properties > Silverlight Application, and you can click the Add button to add content,