About what I read, the EditorTemplates folder must be located under the Shared folder in the Views folder. Is it possible to change this location?
Thank you.
I've always placed my EditorTemplates beneath each view folder they were related too. For example:
If they were "shared" across multiple views I would place them within the "Shared/EditorTemplates" folder.
Is it possible to change this location?
No, that's hardcoded in the MVC source code. Sorry.
Related
I can't find (by string search) any references to the files in my Pages/Shared folder anywhere in my project, but if I remove the folder and its files my test page stops loading correctly. Clearly some kind of implicit convention is at work, but I'm unversed on this matter. Where can I find the relevant information on this?
Files in the Pages/Shared folder are used for reusable parts. The reference, as it is shared throughout the app, is made only by filename or relative path from shared subfolder and without using extension.
You should have in shared folder _Layout.cshmtl and _Layout.cshtml.cs at least. That file is defining layout that is used by default on every page you create.
Once you search for "_Layout" in you project you should get at least one result.
Information about project files for Razor pages are available in Examine the project files and about the layout you can find in Layout in ASP.NET Core.
That might give you an idea how it works by default or what is purpose of said folder and file(s).
You can also read and follow instructions in Understand Searched Locations For The Razor View Engine And ASP.NET to get a bit more understanding how it all works by default.
I want to rename the Shared folder in my Blazor Server project to Components, how can I do that properly? It seems like namespaces are based on folder names but there must be a way right?
You can just rename the Folder to Components. That does indeed change the namespace, edit the _Imports.razor file like this:
#*#using MyApp.Shared*# -- remove this line
#using MyApp.Components
I've been working in a multilanguage site build with asp.net and visual c#.
I'm using Local_resources to get my aspx files in Spanish and english.
If a use my aspx in the root of the website the Local_resources folder find the aproppiate resx for my aspx (because both have the same name). But if i put all my aspx into a folder created in the root directory, everything stop working:
as you can see i have a folder named "Inventario" and inside that folder i have Productos.aspx.
In App_LocalResources i have two files, one for spanish and one for english.
If i put Productos.aspx in the root directory they work fine, but i need them like in the image and like that is not working.
What should i do to the resx files to point to Inventario/Productos.aspx ?
Thank you very much.
You have to create a new App_LocalResources folder under Inventario, then copy Productos.aspx.*.resx from <root>\App_LocalResources to Inventario\App_LocalResources, then rebuild your solution.
I need some help with paths please!
Basically I have a project with the following folder structure:
Project (root directory which contains the .sln file etc.)
Project/MyProj (contains the code)
Project/MyProjTest (the test folder)
Project/TestResults
Now with this Project I need to have a common folder where I can stick a bunch of files for use with the Application without having to copy the files to multiple locations etc. What is the best way to do this? Ideally I would like to have the folder as Project/ResourcesFolder, so that both the Code folder and Test folder can access it. Now if this is the case how do I call this folder from within C#? I've tried Application.StartupPath, Environment.GetCurrentDirectory but they both just return the CURRENT folder which is not what I want.
Thanks in advance.
You can add a solution folder to your solution and place common files in it.
You'll have to copy the files, you'll want your program to operate the same way after it is deployed. The simplest way to do so is by adding them to your project. In the Properties window, set Build Action = None, Copy to Output Directory = Copy if Newer. The latter setting ensures that you don't waste time copying the files over and over again.
This ensures that the files will be present in the same directory as your EXE. Both when you debug and after you deploy it. Simply use Application.StartupPath to locate them. Creating the Setup project for the app is now very simple as well.
Note that if the files are small you really want to embed them as resources.
.. goes one directory up. That is, from Project/MyProjTest you could access Project/MyProj via ../MyProj.
Use Server.MapPath("~") to get to the root folder of your application. From there you can get to wherever you need.
I would like to have App_LocalResources folder outside web application folder, so that I could deploy updated resx files and web app. independent of each other.
Reasons: We do not want to change current deploy tool.
Any way to achieve this?
Way the default resource manager works in asp.net is it picks the resex entries for the respective aspx file from the App_LocalResources folder in the current directory. As far as I know this behavior is not something you can configure (i.e to ask it to pick entries from a different folder!) But there is a workaround, that you could implement your own Resource Manager and let it picks entries from a location you specify it to. Found this and this while googling. Hope that helps.