ASP.NET Web Site or ASP.NET Web Application?

Website:

The Web Site project is compiled on the fly. You end up with a lot more DLL files, which can be a pain. It also gives problems when you have pages or controls in one directory that need to reference pages and controls in another directory since the other directory may not be compiled into the code yet. Another problem can be in publishing.

If Visual Studio isn’t told to re-use the same names constantly, it will come up with new names for the DLL files generated by pages all the time. That can lead to having several close copies of DLL files containing the same class name, which will generate plenty of errors. The Web Site project was introduced with Visual Studio 2005, but it has turned out not to be popular.

Web Application:

The Web Application Project was created as an add-in and now exists as part of SP 1 for Visual Studio 2005. The main differences are the Web Application Project was designed to work similarly to the Web projects that shipped with Visual Studio 2003. It will compile the application into a single DLL file at build time. To update the project, it must be recompiled and the DLL file published for changes to occur.

Another nice feature of the Web Application project is it’s much easier to exclude files from the project view. In the Web Site project, each file that you exclude is renamed with an excluded keyword in the filename. In the Web Application Project, the project just keeps track of which files to include/exclude from the project view without renaming them, making things much tidier.

Reference

The article ASP.NET 2.0 – Web Site vs Web Application project also gives reasons on why to use one and not the other. Here is an excerpt of it:

  • You need to migrate large Visual Studio .NET 2003 applications to VS 2005? use the Web Application project.
  • You want to open and edit any directory as a Web project without creating a project file? use Web Site project.
  • You need to add pre-build and post-build steps during compilation? use Web Application project.
  • You need to build a Web application using multiple Web projects? use the Web Application project.
  • You want to generate one assembly for each page? use the Web Site project.
  • You prefer dynamic compilation and working on pages without building entire site on each page view? use Web Site project.
  • You prefer single-page code model to code-behind model? use Web Site project.

Web Application Projects versus Web Site Projects (MSDN) explains the differences between the web site and web application projects. Also, it discusses the configuration to be made in Visual Studio.

Reference

https://stackoverflow.com/questions/398037/asp-net-web-site-or-asp-net-web-application

Cannot start the web project because administrative privilege’s are required..

While troubleshooting ASP.NET web form project, I hit by this error;

The solution is to Unload  and edit project properties. Delete these lines;

<DevelopmentServerPort>4192</DevelopmentServerPort>
<IISUrl>http://localhost/CPSWEB</IISUrl>

from this XML segment;

  <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
        <WebProjectProperties>
	…..
	----
        </WebProjectProperties>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>

Reload project and it should work fine.

Resources

https://stackoverflow.com/questions/13454705/running-iis-express-with-admin-privileges

The Web Application Project is configured to use IIS

The web project in solution file is unavailable. Project reload show this message;

Here is the solution;

IIS Manager is required to run this web app and IIS Express doesn’t have IIS Manager or any UI. Following solution will work on IIS Express.

When you open Visual Studio and get the error message, right-click the project Solution Explorer and choose “Edit {ProjectName}.csproj”

In the project file, change the following line:
<UseIIS>True</UseIIS>
to
<UseIIS>False</UseIIS>
Save the file.

In my case it was this;

<UseIISExpress>true</UseIISExpress>

Now reload your project.
Done.

You’ll then be able to open your project. If at this point, you want to use IIS, simply go to your project properties, click the “Web” tab, and select the option to use IIS. There’s the button there to “Create Virtual Directory”. It may tell you that you need to run Visual Studio as an administrator to create that directory, so do that if needed.

Resources

https://stackoverflow.com/questions/10889421/the-web-application-project-is-configured-to-use-iis-the-web-server

Git Merge in VS2019

  1. Open project in VS 2019.
  2. Go to menu item “Git” at the top and select “Manage Branches”
  3. There will be a list of your local and remote branches.
  4. Select branch “version2” and right mouse and select the item “Merge ‘version2’ into ‘master’ on remote branches

Sync your branch. That’s it.

nuget package restore

If you are using private feed then make sure you have installed this;

https://github.com/Microsoft/artifacts-credprovider

I ran this command in powershell (admin mode);

iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.ps1'))

I have to run this command to restore packages;

dotnet restore –interactive

This command will open up a window and ask you to login to Microsoft website with a code. Login to https://microsoft.com/devicelogin and enter the code. This will do some sort of IDE verification. Close VS and reopen. You should be able to see all of your custom and nuget packages restored.

I found this alternative today;

dotnet restore projectName

This will restore the packages.

From within Visual Studio you can use the Package Manager Console to also update the packages. This has the benefit that any PowerShell scripts will be run as part of the update where as using NuGet.exe will not run them. The following command will update all packages in every project to the latest version available from nuget.org.

Update-Package

You can also restrict this down to one project.

Update-Package -Project YourProjectName

If you want to reinstall the packages to the same versions as were previously installed then you can use the -reinstall argument with Update-Package command.

Update-Package -reinstall

You can also restrict this down to one project.

Update-Package -reinstall -Project YourProjectName

The -reinstall option will first uninstall and then install the package back again into a project.

Close and restart VS. Hopefully this will restore the packages.

Another problem might be yellow triangle icon next to package references. To solve this, make sure you are targeting same framework in multiple projects. Here is a discussion about this;

https://stackoverflow.com/questions/20186216/why-do-i-get-a-warning-icon-when-i-add-a-reference-to-an-mef-plugin-project

Resources

https://github.com/dotnet/sdk/issues/10189

https://stackoverflow.com/questions/6876732/how-do-i-get-nuget-to-install-update-all-the-packages-in-the-packages-config