Howto add and link to existing WebSite project from ASP.NET project - asp.net

I have an existing Website project; its just one .html and a bunch of .js files (all client-side stuff). This project only has a .sln file, no *.*proj files. It's directory structure is basically:
WEB_PROJECT_ROOT/apps/foo/index.html
WEB_PROJECT_ROOT/lib/*.js
Now I'm working on a new ASP.NET Forms Application, and I need to link to index.html page above, but I'd like to keep it as a separate project (and not just copy it into the new ASP.NET project). It's structure is basically:
APP_PROJECT_ROOT/Pages/*.aspx
I've done Add -> Existing Project and chosen the .sln from above, and it shows up in the ASP.NET solution, but I can't figure out how to link to index.html because it's outside of the ASP.NET project's ~/ directory. Is there are way to symlink to it somehow? Or something else?

Related

How to reorganize contents like the old school in ASP.NET Core MVC?

I have a web site in ASP.NET Core MVC, and I don't want to put my contents inside another folder. I just want to use the old school of creating this file-system architecture at the root of my project's folder:
Styles
Fonts
Scripts
Images
But I can't make ASP.NET Core MVC serving files from them. For example http://domain.test/styles/default.css returns 404.
I've tried to add StaticFileOptions, but I can't get it to work.
Can you help please?
I tried the given solution, that is, to use UseWebRoot("") with empty string to make it refer to the root of my web project. Yet it still returns 404.
I created a Styles folder inside the \bin\Debug\netcoreapp2.0\ and added a Styles.css there and it served the file.
If you are not adding them on the wwwroot folder then you should do more preparation.
This link will help Working with static files in ASP.NET Core
I think before asking you should search some more. For example
this stackoverflow question will help you:
How to Configure an Alternative Folder to wwwroot in ASP.NET Core?

How to select location for Asp.net Website project?

Creating a new website allows you to choose the path of the website files. However, the project file itself is created under the Projects folder. How can I create it somewhere else? I would expect some field for that in the dialog, but can't find it.
(This is not a web-application.)
At least in VS 2013, there is no project file associated with web sites. There is only the .SLN file. The .SLN file is merely a simple container for all of the different websites and projects that you would like opened simultaneously in your Solution Explorer, so the location of the .SLN file on disk is not really important.
Still, if you would like to control its location, you cannot do so through the New Website dialog. You'll have to manually move the .SLN file after you've already created the website. And in doing so, you would also have to open up the .SLN in a text editor and manually adjust all the relative paths to point to your website location.

mvc which files are needed for deployment?

I've been working with webforms and recently started to work with mvc. With webforms, when we use to push to the qa/prod server, we alway copied over the files. leaving behind the .cs files, so just the .aspx, bin folder, along with associated js/css files would go.
with mvc, if we are copying the directory over from our pc (where we develop), what files are needed, do we need the .cshtml files for example? I just want to avoid having to push all the files if they are not needed.
They are definitely not all required. What you are going to want to do is setup a way to publish, this ranges from doing a "bin deploy" to feeding in ftp settings and using a "single click deploy" approach.
What it all boils down to though is this. You will need
A bin folder with every relevant .dll
A content folder with relevant images and css files
A script folder with relevant .js scripts
A views folder with nested folders for views with relevant .cshtml files
A .webconfig file in the views folder and also one at the very root
The packages.xml file at the very root
The global.asax file with markup pointing to the application starting in global.asax.cs
What this excludes is every single .cs file. These will all be composed into your projects .dll. So if you are developing FunWebApp, then all your c# will be rolled into FunWebApp.dll in your bin folder.
Use the Visual studio "Publish" option available on your UI Project. This will generates all the required files you neeeds includes, bin folder, Views folder(which will have the .cshtml files),Content folder,Script folder, Config file(web.config) etc.
Right click on your project and select "Publish". You will be shown a wizard where you can define what kind of publish you want. You have different options like FTP, File system etc.
You will not see the Controllers folder / Other class files because code inside that folder is compiled to your assembly which is in the Bin folder

reference app_code classes in web application project

I have created an asp.net website, with the accompanying app_code folder.
In the same solution I added a web application project, and I want to use the classes that are in the website app_code folder.
I tried adding a reference, and then adding the project (the website), but the list of project is empty...
Thanks.
You are doing it wrong. Create a class library project and move all those classes from the app_code folder to the new project. Then reference this project from both website and web application project.
Very late, but sometimes classes in App_Code may need to stay in the same project, then
Create a new folder (say "code" )in web application, and add class files from app_code as links to this folder. This lets you have a single copy.
2) Ensure Build Action for each of these imported files are "Compile" in the file property folder if need be.
3) Exclude App_Code folder from web application.
More information and reasons - please see here:
http://vishaljoshi.blogspot.in/2009/07/appcode-folder-doesnt-work-with-web.html

How to create a solution file using vs 2008

I have all the files for the deployment listed below :
-BIN
-CSS
-IMAGES
default.aspx
PrecompiledApp.xml
Web.xml
The above files can be copy pasted in the webapps folder and default.aspx could be run from the browser.
i want to create a solution sln file from this. How to create a solution file?
A solution is merely a container of projects. If you create a project containing these files, the solution file will be created automatically in the same directory (unless you specify otherwise).
File -> New Project
Expand Other Project Types, Select
Visual Studio Solutions
Under Templates, ensure you have
selected Blank Solution
Enter a name and a location for the
solution and click OK
File -> Add -> Existing Web Site
Select the folder that contains your
website and click Open
It looks as though you are creating a web site. I've never been able to create a solution with just a website in it (a web application is a different beast however). However, I have found a workaround, although it's a little cludgy. Create a new class library project (any project type will do really). This will create the project file. Then File -> Add -> Exisiting Web Site. Point to your existing web site and add it. This will create the solution file as you now have two items. You can now delete the first project that you created. This will leave you with a solution file with one web site in it.

Resources