Where is the site.css file located for Identity? - razor

I have an asp.net core 2.1 MVC application. I have ran the Scaffold Identity which has generated all the HTML and models used. I can't however find the css file that identity is using for its layouts?
In chrome developer tools it tells me site.css is being loaded from /Identity/css/site.css and bootstrap is being loaded from /Identity/lib/bootstrap/dist/css/bootstrap.css. These files don't seem to exist anywhere in my project. Am I missing something?
It's not using the site.css file that's located in wwwroot/css.

The Identity default UI is a Razor Class Library. The static resources are being embedded and loaded from the library. Specifically, the Static Files middleware is loading up the embedded resources as if they were on the filesystem, using a ManifestEmbeddedFileProvider.
Long and short, you can override those by simply creating files in the same location in your project. Then, your project's versions will take over. Unfortunately, the scaffold doesn't provide a way to scaffold static resources as well. However, you can simply view the source in your browser and then copy that into your project's version of the file.
You can also view the source of the RCL here. That way you can reference whatever code you need, without even needing the scaffold. Anything you add to your own project overrides what's coming from the RCL.

Related

Vue-Nuxt: Why can't I see the generated HTMLs correctly?

So when I type npm run generate Nuxt generates my project into the dist folder. In that folder I can find a folder called _nuxt where I have .js files and the index.html file but when I open it in a browser it doesn't show anything.
So, my question is: Aren't those static files?
When you work with the CDN served vue.js you have the html file and you click and everything is showed on the browser because those .html files are static, they don't need an internal localhost server. Why npm run generate doesn't do the same? Or how can I see those generated files?
As #aljazerzen explained, Vue,js doesn't do SSR out of the box, one of the aims of Nuxt.js is to provide SSR for you, as a benefit you can also generate a static version of your website. If I get what you want correctly, what you want to do is that when you open your index.html (the one that Nuxt.js generates for you) you can see your functional webpage. When you're accessing your website as a file:/// url, your browser (at least I've seen it happen with Chrome) doesn't load your .js files.
I don't have any Nuxt generated websites at hand so I can't tell you exactly why this happen. But this is my guess: when Nuxt generate those files it gives them a src that can't be accessed as file:///, maybe something as /your_js.js, that when it tries to load it, thinks it's the / of the root folder instead of relative to your website's root (/).
The solution to this problem is to serve your assets using any web server. According to Nuxt.js's documentation:
nuxt generate :Build the application and generate every route as a HTML file (used for static hosting).
You could do a quick test and use a simple web server by typing:
python -m http.server
In the folder that contains your generated assets.
Hope this helps!
Nuxt uses server side rendering.
You can read more here.
To generate static HTML files, run:
nuxt generate
Explanation: Vanilla Vue.js application is rendered only when the page loads and JavaScript can start running. This means that some clients that do not have JavaScript enabled (web crawlers) won't see the page. Also for a brief second before Vue.js can render the page, there is blank screen, when plain HTML files could already be visible.
Now, server-side rendering (SSR) is a technique for rendering a single page app (SPA) on the server and then sending a fully rendered page to the client. The client’s JavaScript bundle can then take over and the SPA can operate as normal.
This can also help with SEO and with providing meta data to social media channels.
But on the downside (as you mentioned), such application cannot be hosted at a CDN, since you have to have a Node.js process running to render the page.
In my opinion, SSR is redundant with SPAs if what you are building is actually an application and not a website. A website should mostly display information and should not be interactive. It should leverage web-based mechanisms such as links, cookies and plain HTML with CSS. In the contrast, web application (eg. Vue.js application) should be more like a mobile application: it is larger to download, but performs better and offers much more interactive experience. Such application does not need server-side rendering, since we can wait for it to load a bit more and because it shouldn't be indexed by search engines (it is not a website).

In CKAN, is it possible to override templates of customized extensions?

I created a CKAN extension for blog. The blog extension overrides ckan core template files and working fine.
Then I created another extension called ui, to create a new template for ckan. In this new extension can I override my blog extension's template files?
For example: if I have 'blog/templates/blog_post.htm' in blog extension, can I override it in ui extension by '/ui/templates/blog_post.htm'
This way I can keep my extension working with ckan template and it working with my new templates.
Yes, you can override template from other extensions. You just need to be careful with the order in which you load the plugins in your ini file (the one overriding the templates should be loaded first).

Upload files from external library?

I've added my cms as an external library in PhpStorm:
I just wanted to know if there is an option to upload (deploy) these files too? I always have to switch to my cms and open it itself as a project to be able to upload its files.
I've found nothing in the documentation also.
If it's not part of the project root/outside of the project -- then no.
But you can make it part of the project by:
adding it as Additional Content Root (Settings/Preferences | Directories) -- it will be listed as additional node in the Project View panel (similar to actual project's main folder)
or just symlink it (e.g. a subfolder inside the project root that is symlink to outside folder).
Please note that in both cases such folder becomes part of the project so the search routine will take those files into consideration as well as other functionalities (find usages; look for errors in a code; TODO's etc.). You may also accidentally edit your CMS core files and IDE will not tell you anything (in case of External Library it will notify you about this).

Linking from HTML page to MVC view

I have a legacy site that uses shtml pages. I have a project to add dynamic functionality to this site -- an MVC app where the user uploads files and the controller generates an email.
For legacy reasons, I am not able to rewrite the site. I also do not have web admin access to the site; I can only work with files in my area. The path I have to work with is //host/foo/bar/baz.
According to this Stack Overflow question, I ought to be able to make a link in the originating static page within the directory baz as link text. I tried that, and after fixing up issues with the app's web.config file, I got a 404 error. This does make sense now that I think about it, as there is no directory in baz called Controller -- only bin, Views, and the like. The physical path not found is foo/bar/baz/Controller/Action.
There are plenty of articles and Stack Overflow questions about adding a static page to an MVC app, but I have found nothing discussing the other direction.
How do I link from the static HTML page to the MVC action?
(I may have follow-on questions as I try to get the app to run.)
Edited to add:
I tried moving the MVC app code to the top level of the web site (in my development environment). When I used the link this time, I encountered a configuration error in my IoC file, with mismatched versions of Entity Framework. This approach might be promising, and it also might encounter permissions issues in the operational environment.
Also, I do not have write permissions to the root level of the web server's documents area, only my subdirectory area.
link text
Try with "/" before controller

How do I configure a Web Application project for working with html pages without .Net code?

We have a few html pages in one of our solutions that are meant to be extremely simple, client side only, pure html+javascript pages that access our web api. The api itself is in a web application project in the same solution.
We are now using a web site project to contain those files, but it is getting harder and harder to manage that project, since it's information is placed on the solution, and most of it's aspects cannot be controlled like they can on a msbuild project file.
I'd like to migrate those html files to a web application project, but I'm struggling to make it as basic as possible. For instance, I do not want to generate any dlls on the project. It should be in the solution just to provide access to the files and to enable us to control what goes to the _PublishedWebsites folder on the build by setting the build action on the files. We need this because there are some miscellaneous files in the project that should not be published.
I tried creating an empty web application and removing most things from it, by editing the csproj file. I managed to delete all references and the whole Properties special folder (along with the AssemblyInfo.cs file), but when I run the build command, I still see a dll created along with the obj and bin folders. Then, I tried faking the build target on the csproj file, like this:
<Target Name="Build" />
Now when the project is built, no dll/pdb is created, but the obj and bin folders are still there. Next, I tried setting the outputpath property to the current directory, like this:
<OutputPath>.</OutputPath>
But even then, the obj folder is still created.
EDIT:
I just found another common msbuild property that controls where the files inside the obj folder are placed. After placing this in my csproj file:
<IntermediateOutputPath>.</IntermediateOutputPath>
I now get no folders generated on build, which is nice.
There is a small problem now though (and I'm not sure how and where exactly this process happens) when I open the solution or reload the project in Visual Studio. Even though the project is not being built at this time, some files are still generated:
I feel the current approach is enough for my requirements, yet I'd really like to know if there is a more elegant way to achieve that. Thus, the question holds: Is there a way to make the web application project work as if there was no code file in it, effectively disabling output generation (bin and obj folders, and the dll/xml/pdb outputs)?