I was wondering how can I add / change styles in an ASP.NET MVC project in VS 2019.
folder with less files in content folder
I can see this folder with style files when I inspect the browser, but if I go to project folder itself, there is no such folder. I could add additionally a css file, but I was wondering where is this less folder with all the style content, why it is not displaying in the project explorer?
Thank you,
darya
I'm not entirely sure, but it sounds like you're using a CDN. CDNs won't show up in VS because they are pulled in when the page is loaded.
Related
I am new to ASP.NET and I was asked to create a portal program which will be just a part of the existing ASP.NET portal project. Meaning, it will be just like 2 web pages and will be going to be added to the existing project. The thing is I have to do it in a separate ASP.NET Project file. I have the source code of the existing main project but I am not allowed to modify this unless the pages that I will develop are completed. How can I do it? I know I just have to create a new project but what is the next step after that? How can I import the one that I made to the main project? They mention that I just have to export it as DLL but I have no idea how to do that. Please help me.
Open your new project in Visual Studio.
Open the old project in Visual Studio.
Right click the name of your new project on Solution Explorer, select Open Folder in File Explorer
Copy the 2 new pages you created
Go to the Visual Studio Instance of your old project. Click the name of the solution and CTRL + V or Right Click > Paste. (If there is a folder let's say Pages where ASPX files are located, click and paste there instead).
Your new files might not be included in the project and if its happens, click the 'Show all Files' option on the Solution Explorer.
Right click on the 2 new ASPX files and select 'Include In Project'.
I am not sure if I understood you right. If you just have to export the dll from the project that you created, right click on your solution, open the bin folder, you will see a file named yourprojectname.dll. Copy this to your target projects bin folder using the steps mentioned above.
If I understood it right, you are being asked to created a classlibrary or something and not an aspx page. Again, I might be wrong, but others can help you if you are lucid about your requirement.
I have multiple ASP.NET MVC5 projects that use several similar styles/scripts, and I think, for maintenance's sake, it'd be ideal to have a separate project in Visual Studio 2013 containing the LESS stylesheets and JavaScript files that can be shared between the two.
My setup is as follows:
Web.Project1
Web.Project2
Web.Assets //would contain LESS/JS files
Resources
Domain
Data
Any pointers?
I've been looking at adding as a link, but I'm not certain that would accomplish what I need.
I recently went through this process for a project of mine, and concluded that if your goal is simply to avoid duplication by keeping your code DRY then using linked files works great.
It's simple enough to do, but I'll write it up anyway as it might save someone some time.
Quick Summary
Create common Solution Folders containing the resources to be shared, or simply designate one of the projects to be the master.
Use "Add as Link" to add the shared resource files to each project as needed.
Add an AfterBuild task to each project file that will copy the linked files to project folders. This is only needed so that Visual Studio test/debug (F5) will work locally.
Detailed explanation follows:
Configuring Solution Folders for the Shared Resources
** Note that if you're simply going to share files directly from one project to one or more additional projects then you can skip this step.
Visual Studio solution folders do not have to reflect physical file system folders, but doing so will help preserve your sanity. So first create the folders on your local file system and copy the resource files into them. The new folders should be located under your solution folder. For example:
\MySolution
\Common
\Images
\Scripts
\Styles
Back in Visual Studio, right click on the Solution Items folder and use Add Solution Folder to replicate the new file system folders.
Next, add the files to the new solution folders by right-clicking each folder and using Add Existing Item to add the contents of the folders.
Add Shared Resources as Links
For each project that will use the shared resources, right-click the project folder and choose Add Existing Item. Browse to the common folder, select the desired files, click the drop-down arrow next to the "Add" button and choose "Add as Link".
You may get a source control warning about adding files that are outside of the project directory structure, but this can be ignored since the linked file will be under source control at its source.
Add an AfterBuild Task to Copy Files
When you publish the application to a server the linked files will copied to the project folders to which they are linked and everything works as expected. However, in the development environment the linked files do not physically reside in the project folders. So when you hit F5 to test your application in VS, the shared resources will be missing.
The simple solution is to add an MSBuild task to copy the linked files from their source after each build. This needs to be done to for each project that contains the shared resource links.
Right-click the project and choose Unload Project. Right-click the project again and choose Edit <ProjectFileName>. Scroll to the bottom and add the following (just above "</Project>"):
<Target Name="AfterBuild">
<!-- Copy linked content files to local folders so that they are available in the debugger.
This is only an issue when running the application locally. The linked files should
be automatically published to the correct folder when publishing to a web server. -->
<Copy SourceFiles="%(Content.Identity)"
DestinationFiles="%(Content.Link)"
SkipUnchangedFiles='true'
OverwriteReadOnlyFiles='true'
Condition="'%(Content.Link)' != ''" />
</Target>
** Copy task adapted from this link.
Save the project file then right-click and choose Reload Project.
For some reason, my shared folder ,which contains some error pages and my master _layout.cshtml page, is hidden. I can only access it when I click on show all files in my solution explorer. This is not a real problem, everything still works but I know this is not standard.
I don't know how this folder became a hidden folder, but does anyone know how to set the folder visible?
When I browse to my project folder in my file system, the folder is not a hidden folder...
I use Visual studio 2012, os = windows 7 64 bit
Just a wild guess here, but can you right click it (in Visual Studio) and "Include In Project"?
It will not be included in your .csproj file.
To include it, either open your .csproj file in notepad and add in the lines or remove the folder from the project and add it back in.
When we publish mvc-3 project to windos azure, Is it copy all files and folder under the project name folder, means likes Scripts, Contents, etc ?. I am asking this because i just publish my mvc-3 application to windowsazure and after that when i run it using staging url then it not shown the images, plugin are stop working and when i inspect under chrome then it shows :
If you notice than there are few Scripts ( like sammy.js ) and stylesheets ( like Site.css ) which are present but maximums are not. Can please anybody explain me how can i fix this?
Ok , i found out the root cause, this is happening because each time when i was downloaded the new plugin
i just copy the .js from its source folder and then paste it into my project's Scripts folder. But only after
putting the file inside the Scripts folder does not includes it in the project. You can`t see that file in the
solution explorer until you explicitly include it in the project.There is a button in the solution explorer on the top
of it for show all file, included the files which are not the part of the project.Then Just right click on the
file which you want to included in the project and select option Include in the project. Then only that
file becomes the part of your project. Now you can publish the project and everything will works fine.
Make sure they are included in the .csproj file
Make sure they are marked as Build Action: Content
I am using visual studio 2005, (.net version is 2.0+) to create a windows application. The functionality of the project is matching with the ideal design, there is just one problem in publishing the project.
I use MouseHover method to change the picture(image) used in intention to make attractive UI, when I hover the mouse pointer over the picture .. some other pic is loaded in-place of it .. and in mouseleave method the same picture is retained back.
Now the problem is while debugging this functionality works properly,
But when published, and used, the window won't load the image (as the installed folder doesn't contain these images) .. How to bind the supporting files like images, text files and any other files like xml with EXE??
I mean is there any ideal way to publish the project??
In your project, ensure that the images are set to Copy Always or Copy if Newer on the Copy To Output Folder property (F4).
That should ensure that when doing an XCopy deploy the images will be in the right folder (you will proabably need to change the logic for finding the image paths, so the application finds them in the right directory).
If you are using deployment project that will generate .MSI for your application, just right click on the project, click add files and then pick the images from your project directory.
Those files will be (by default) be deployed into the application target directory, and your end-user app will be able to access it.
You can package them as Embedded Resources.
To embed them, make sure that when the resources are selected in the Solution Explorer that the 'Build Action' in the Properties window is set to 'Embedded Resource'.
Here is an example with sample project on how to embed images : How to use embedded resources in .Net