ASP.NET MVC 4 IncludeDirectory from a another referenced project - asp.net

I'm facing out a strange problem while using ASP.NET MVC 4.
I have 2 "Web Site" projects:
The first named "MyWebSite"
The second named "MyWebSite.Support"
I need to include the scripts under MyWebSite into MyWebSite.Support, so i thought to create a bundle in MyWebSite.Support and to reference that directory (MyWebSite/Scripts) inside that bundle by using "IncludeDirectory"
The problem is that i didn't found a way to correctly do that. It simply doesn't work because the starting path for the IncludeDirectory should be "~", which is the project virtual root path.
PS: If you have another solutions they are welcome!.
I don't even know if it's a good solution (i usually am not a everything_related_microsoft developer)

You could add the scripts as a link to the other project. This will assure you that they are copied when you deploy and you can use them in bundles. To do that, right-click on your scripts folder and select "Add existing item". In the dialog box select the files you want to add. Instead of clicking "Add Item", click on the little arrow next to it and select "Add as a link".
This will not actually copy the files, but include them as a linked file.
This has several advantages:
Files are shared between projects at Design time
You only need to share the files you want, not everything
You don't need any IIS configuration
You can easily edit the same file from each project (without copying it)

Related

ASP Site - Updating Dlls on Change

When I make a change to the a aspx.cs page in my website and then build I notice that none of the dlls in the Bin folder are updated, the only dlls I can see in there are the references the web app uses. I want to bring across this one change rather than redeploy the whole site so where are the changes being saved?
I've tried various things like build solution, rebuild solution, build website, rebuild web site.
Is it possible my dll is being sent elsewhere? How would I go about finding out where?
In Solution Explorer, on root project node, right-click and select Properties. Click on the "Build" tab and look under "Output" section. Here you will see the actual output path and can change it to your bin folder.
In Solution Explorer, on root project node, right-click and try to Clean solution and then again build whole solution.

Centralised web.config in Asp.Net

I have almost 20 projects in my web solution which include asp.net web application and windows service projects. These all project contains web.config and app.config respectively.
Now I want to remove this all files and want to place a single web.config file in the solution which will be accessed by all the projects.
Can anyone suggest me of doing this ? If yes then how the projects will call the web.config from the solution root ?
try to use Shortcut/link instead of physical files. to achieve this:
keep only one app.config file (the one you edit most frequently probably, does not matter from which project)
at each of the rest projects, remove existing app.config file, then right click your project (or the folder you want to place this app.config), click Add, then select "Existing Item...", at the popup, select the physical one you kept in step 1 and then click the arrow next to the "Add" button, select "Add as Link".
now then all the projects (except the one you selected) will reference the one you kept as a link (shortcut).

Publish only edited page in asp.net

Whenever I update a small part of my website I have to upload whole website again.
If i upload only edited part it throw me exception.
The way I upload my website:
For example if I have 4 pages (home, register, about me, contact me) and if I update home.aspx, I publish whole website in a local address, and then I compress it with zip format and upload it manually.
Is it possible to publish only updated part?
It is not possible to publish only a part of website, but what you can do is to choose Single-File Assembly build option ,by this you can get single assembly for your page.so intead of updating whole application you can update only the pages you change
read more
What I always do when publish ASP.Net Webform project, I complate it with two steps. Maybe this way suitable for you.
When you use publishing tool on visual studio by selecting Build menu -> Publish, you can choose "File System" as "Publish Method", type your "Target Location", and select "Replace matching files with local copies". It mean the project will publish modified files only.
After publishing have done, Open defined "Target Location" using windows explore and sort by "Modified Date" and just copy newer modified files for each directory recursively to your server.
If you build the website pages into dll. You can not published only the aspx. there are many other dll and compiled files in bin folder, we don't know which matches which aspx.
If you only edited the "view", i mean, the html and markup part of <%%> code, and no code behind (.aspx.cs) change, you can published only this aspx. But remember to set website as updatable in the publish dialog.
I suggest you to compile the aspx into one dll. according to #Buzz 's answer. Then, your aspx files would be only an empty file. All you need to do is upload only one dll to the bin folder.

Published project files ignored

I've been trying to publish my Visual Studio 2010 project. I do this by accessing a hard drive which corresponds to a URL, so X:\Options\Forms\HD\ corresponds to /HD. Yet when I go to the URL, it says I don't have a default.aspx page. Yet when I look in the corresponding file directory the default.aspx page is right there. Why is the browser ignoring it? Another issue I have is that not all of the files are getting published when I select the option in Visual Studio; many are left behind including my default.aspx.vb file.
To make sure files get published, make sure that they have the correct Build Action set (check the Properties window for the file). Especially, if it is set to None or if the files are not part of the solution/project they won't get published. The "Content" build action is a good choice for any file that just needs to be published.
Extra tip: for files that VS doesn't know the default build action is None. You can however configure VS to use whatever build action you want.
I've written about it here: http://blog.andreloker.de/post/2010/07/02/Visual-Studio-default-build-action-for-non-default-file-types.aspx
Also, I've created a simple tool that generates the necessary configuration file: http://tools.andreloker.de/dbag

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