I'm refactoring a legacy code and one of the things it must be done is moving related controllers into a new folders. The thing is that it is a huge project and if I move the controllers I will need to redefine the paths on controllers and views which is quite impossible, also with the addition that maybe I will forgot something that it is no properly tested.
Is there any way to move controllers into folders without affecting the routes? Or is there any way to redefine easily the path of the resources? OR is there any easy way to say that a namespace don't has to add a prefix like 'api/controller#action? (don't add 'api/')
Thanks in advance.
For those how migth need an answer to this question it is on http://guides.rubyonrails.org/routing.html Just check 2.6 Controller Namespaces and Routing and you will find this:
Related
When you have a server side blazor app and you reference a razor class library directly (at the moment I am using dotnet5) it seems to automatically add the /_content/.bundle.scp.css by adding an #import to the .styles.css. This appears to work well enough at least in debug just by adding the reference and hitting F5.
I see conflicting documentation adding the links manually in many places and they are generally being added in the head as links, not as an #import. I am guessing this is maybe something that has changed since core3. I also have not figured out where the bundled files are supposed to "live" while you are still developing, when you publish you end up with a \wwwroot_content folder, but a development that appears not to exist on the filesystem and actually be mapped onto the \obj folders of the individual RCLs.
In the app I am currently working on the razor class libraries are loaded at run time, so this does not work automatically, for the time being I have the bundles referenced as individual links programmatically added in the head of the _host.cshtml after I copy them from the individual RCLs' obj<BuildFolder>\net5.0\ as that seems to be the only place they exist on disk. I am also serving them with an app.UseStaticFiles out of another folder since I am still unclear on how the inbuilt folders are meant to operate.
When I first figured out that the runtime load was an issue I was able to get confirmation there was not inbuilt support beyond direct references here https://github.com/dotnet/aspnetcore/issues/33284 and I started looking for how to re-implement the existing work-around more properly.
I would prefer this to work as similar to a directly referenced RCL as possible, but I am not finding any information on if the bundles are meant to be referenced globally at all times or conditionally, I do not see any obvious way to get them to be added as an #import programmatically, and I have no idea what the implications of trying to manually create the _content folder from the bundle files found in the various \obj folders would be.
How this is really supposed to work in development and when publishing? Is what i am doing even close or is there some glaring issue I will be encountering down the road?
It seems that in ASP.NET Core MVC, if I want to use a View Component, I have to put them in Views\Shared\Components\[ViewComponentName], and then name the file "Default.cshtml".
This is rather frustrating, as in the beginning of a large project I am helping to port from Perl CGI, I'm creating a good number of View Components and having five tabs in Visual Studio all named Default.cshtml is confusing.
Is there any way I can avoid this naming convention? Maybe even take them out of their folders so that the file will look likeā¦?
Views\Shared\Components\[ViewComponentName].cshtml
I don't know if there are just some settings I can tweak or what. For the most part, I'm very new to ASP.NET, and still figuring things out. Using ASP.NET Framework instead of ASP.NET Core is an option, though I'd prefer not to, as a lot of the boilerplate is already done.
The documentation on ViewComponents says this:
We recommend you name the view file Default.cshtml and use the Views/Shared/Components/{View Component Name}/{View Name} path.
Which makes me think that there is a way around this restriction, but it doesn't specify how that would work or what it would look like.
Like Nic I agree that having several to dozens of files named default.cshtml is annoying. More so is having several to dozens of folders with just a single file in each folder
Components/ViewComponentName/default.cshtml
Components/AnotherViewComponentName/default.cshtml
Components/AThirdViewComponentName/default.cshtml
et cetera
I understand the reasons for the recommended name and location...but I simply disagree and will accept the consequences. For those who share my cavalier attitude, View() allows you to specify a View name
return View("Schools", items);
or even to specify a path to the View if you put it in a non-standard location
return View("/Pages/Components/Schools.cshtml", items);
I'm using Razor Pages but I'm sure this works for Views/Shared/Components as well.
We have been using Yii for building web applications. Once in a while, themes comes to our discussion table.
But, if we have a web application and we wish to change the look and feel only, we may, as well, change the public_html folder, since the structure will be similar.
The only point we see on having themes is for those cases where we may want to dynamically (user choice by clicking on a "change layout button") change the look and feel of an application.
Does anyone uses themes for any other proposes, or configurations?
We use themes to great effect. We operate 6 sites using as single instance of a Yii application. The theme is then selected based on the domain name.
Yes we could have just used 6 different application folders and served them separately. This comes with several advantages though, which you've probably already dismissed if they're not relevant to you, but here they are:
Shared code, updates and maintenance are far easier
Adding a new theme is much cleaner IMO (just a new theme folder rather than a whole application directory)
Global assets, which are then overridden easily in the theme, rather than wiping over them completely, you'r expanding them.
Shared Cache, the whole application caches to a single directory, view cache, data cache etc.
Shared Assets directory, assets are only published once ( although this could in theory be set up in a copied environment)
I much prefer this set up, it looks far cleaner just to override rather than overwrite. Plus really, I can't think of a reason why copying the whole directory would be better than this method, yes there are issues in theming that have to be worked out, but copying the whole source doesn't solve them.
I am currently trying to get to grips with bootstrap and am struggling to understand where I should be editing the CSS. I created a custom.css.scss file to edit settings in my app/assets/stylesheets folder however when I add rules they often seem to be overridden as such I have found that I have to edit certain elements by going to the external libraries bootstrap-sass resource and drilling down to the ../stylesheets/bootstrap folder where I then have to hunt for the relevant style to change. I am sure I am doing this the wrong way, is there something I should be doing to ensure my custom.css.scss has priority? Any help much appreciated!
You don't want to edit the bootstrap files themselves, but CSS rules have a precedence structure which determines which CSS rules are used. It is not terribly complicated, but is a bit tricky until you get the hang of it.
Smashing Magazine has a relatively good introduction to it with links to other sources as well.
In the application.css found in the assets all other styles are included you just need to change the order of these like mentioned here: Rails 3.1 Load css in particular order.
I use Tomcat 6.0.20 and JDK 1.6.0.13.
How can I load libraries from sub-folders of %TOMCAT_HOME%/lib/ without taking the .jars out of sub-folders and putting them straight into %TOMCAT_HOME%/lib/?
The reason I want to do this, is because many apps are going to be sharing lots of libraries.
So, for the sakes of organization I want to store them into folders as such:
%TOMCAT_HOME%/lib/novell/*.jar
%TOMCAT_HOME%/lib/mail/*.jar
%TOMCAT_HOME%/lib/upload/*.jar
etc.
How would I go about this? And please provide an example.
Do I use setclasspath.bat, catalina.properties or something completely different?
Thanks in advance.
Define those paths in shared.loader property of /conf/catalina.properties file.
E.g.
shared.loader = ${catalina.home}/lib/novell/*.jar, ${catalina.home}/lib/mail/*.jar, ${catalina.home}/lib/upload/*.jar
[Edit] optionally you can also use the common.loader property for this. See what has your preference.