I'm trying to generate an xml sitemap for published Umbraco content. Ideally I'd like to access UmbracoHelper.TypedContentAtRoot() or something similar that gives easy access to published items. I need to access it outside the web solution, inside a supporting assembly where I'm generating xml sitemaps and sitemap index for dynamic content outside the direct control of Umbraco.
Any ideas about the easiest way to go about this? I've tried referencing various Umbraco assemblies and digging into what's readily available but haven't found anything immediately useful yet.
I have stumbled across
UmbracoContext.Current.Application.Services.ContentService.GetRootContent()
but this seems to require a much deeper understanding about how Umbraco content works under the covers in order to drill down to extract published content for me to index.
Can anyone point me in the right direction? Thanks in advance!
Assuming the DLL you are creating is going to be using IN the umbraco site, you will be able to access UmbracoContent.Current in your classes, as long as you've got a reference to the Umbraco.Core package, as Mivaweb states.
If on the other hand you want to access the UmbracoContext from a completely unrelated external application (say an executable file), then that it MUCH harder to do. A few people have got it sort of working, but it's a bit flakey. Usually in this case, you're better off adding some kind of WebAPI controller action that you can call via HTTP from your executable file, so you have full access to Umbraco on the site.
Update:
If you just want to access the typed content, you can get at it by using:
UmbracoContext.Current.ContentCache
This will allow you to do stuff like:
UmbracoContext.Current.ContentCache.GetAtRoot();
Which will get you all of the root content of the cache.
If you have a seperated project where you would like to do Umbraco stuff then go to the nuget package manager and install Umbraco.Core.
This will install only the necessary Umbraco dll's that you then can use.
Then you just need to include the namespace and you are ready to go.
Related
I am working on an MVC project (.NET Framework 4.7.2) that uses AspNet.Identity to control access to pages. I have some static documentation files generated by TypeDoc that I wanted to be able to control access to. Serving the files proved to be no problem, I just created a wwwroot directory and put the files in there. The files can then be viewed via a URL of the form /wwwroot/index.html (etc.).
However, since these are documenting the code, I wanted to be able to lock this down. I have seen articles on how to do this in .Net Core but have yet to track down how to do things using AspNet.Identity. There is, of course, the laborious way of doing this - i.e. recreating every page as a view with a controller and applying a tag like [Authorize(Roles = "Developer")] to the controller but this would defeat the object of being able to generate these files automatically.
The project has out-of-the box files such as App_Start/Startup.Auth.cs and Controllers/AccountController.cs that include AspNet.Identity code, so I am guessing I may need to put some additional code in one of these.
I also note that serving the static files works despite not adding (or finding) any code like app.UseStaticFiles();, as used in .Net Core.
Any advice/pointers on this would be greatly appreciated!
I'm unable to get server side includes (*.html files) working in a .net core razor pages web application. I've made sure to have the appropriate handler in my applicationhost.config, but I'm thinking there's a different issue here. Any help is appreciated.
Why am I doing this? I have multiple web applications sharing the server side include files (for navigation bar, footer, head content, etc..). Each of these different applications may be of different Microsoft web architecture. Our goal is to move everything to .net core, but we have lingering web forms projects to deal with along the way.
I have performed a work around by taking the SSI file contents and using #Html.Raw to serve up the content. This is probably wrong also.
I went ahead and changed the file extension of the html files into cshtml which allowed me to treat these files as partial views. I'm using a prebuild event to copy these files from a shared solution folder into my project Pages/Shared/ssi folder. I also copy those partials into wwwroot/ssi for the other applications to use via SSI. Eventually all of the apps will use the partial views instead.
The problem with this solution is that it is not necessarily clear that all edits need to happen in the shared solution folder instead of directly in the project, but the documentation for the project will address this. I tried using linked files, but only one link to a specific file can be made in a project.
Not a perfect solution (to the problem), but this not a perfect website either.
I'm trying to create a wpf application such as a movies library because i would like to manage and sort out my movies with a pretty interface.
I'd like to create a library with all my movies getting information from the web, but i don't know how very well.
I thought to get the information from a web site, for example imdb, but i don't know if it's legally to capture html from page to get the nested information.
It's my first desktop application and I would also like to know if it is necessary to create a database within the project and then create a setup project with specified script for deploy it.
Sorry for the confusion but i would like to know too much things :)
Thanks a lot in advance.
The legality of web scraping is a grey area. See my question, "Legality of Web Scraping vs Normal Use" and the corresponding answers for some insight.
Even if the legality is not a problem, web scraping is a flimsy approach because the webpage structure may change without notice, making your application suddenly useless until you update it to the new format. You are much better off using some sort of web API (if the site providing the information offers it).
Whether you need a database or not depends entirely on what your application will be doing and how you design it - it's not something any of us can tell you.
Same goes for the setup project - in fact I wouldn't worry about that until you actually have a working application. Take it step by step and keep the scope within control.
Yes I did not think about api.
It's a great idea, maybe use "themoviedb".
But if i create an application based on it, that has to show all the movies that you have stored on your hdd and get , for example, the posters, the description and the ranking, i have to create a database according to you?
Thanks a lot.
I'm currently looking to replace the in-built "DirectoryListingModule" in IIS 7.5 with a custom version to make the listing a little prettier. The problem is I cannot seem to find anything on the subject of writing a managed module to do this myself. I've read the IIS 7 module/handler tutorials over on Microsoft's site, which are helpful albeit very basic. I've also seen Mike Volodarsky's implementation but unfortunately no source code is provided. The only other resources I can find link back to either Volodarsky's blog or the Microsoft page (which is also written by Volodarsky!). I guess what I'm saying is I don't know how to get from the basic module in the Microsoft tutorial to the directory listing functionality of Volodarsky's example.
If anyone can provide a hint on how to tackle this I'd be very grateful. Also please let me know if any of this isn't clear (I'm terrible at writing).
Thanks in advance :)
Edit - Just to be clear, I realise I have a lot of reading to do and am not looking for anyone to do my work for me.
Mike Volodarsky's implementation is really simple:
you create a module that intercepts requests to "directory" urls within your application.
This module will create a collection of object that rappresents directory structure and save it in the httpcontext
Then you load an aspx page which binds to the httpcontext saved content.
I don't get what you are asking for?
If you are not able to develop that module you can use the Mike Volodarsky's one and just customize the aspx page...
The PreRequestHandlerExecute event in an ASP.NET Application is where you can process and replace the default IIS handlers.
You have two option:
Use the Application_PreRequestHandlerExecute event in the Global.asax file.
Write a custom IHttpModule and use the OnPreRequestHandlerExecute event.
Regardless of which method you prefer to use, you must ensure that the request is a directory not a file, other registered handler, and so on.
Use the below code to check for it:
if (!Directory.Exists(context.Request.PhysicalPath))
return;
I have an web based application. The content for the Home page has been currently mentioned in the HTML code for the Home page using , and tags. To change the content anytime in future, it needs to be changed in the HTML code. :(
Is there a way that we can pick up the content from some external place and get it reflected through the website. This ways, any change if required can be made at the external location without referring to the application's code.
Please advise if there is any solution for it.
Thanks.
You can
Use a database
Include external files using Server Side Includes
Read external files and write their contents and an alternative method
Sounds like you're looking for a Content Management System (CMS), which will allow your content editors access to modify only specific blocks of a page that you specify.
There are a ton out there to do what you want, so you don't have to start from scratch. Just Google 'CMS'.
Although I haven't used it myself, DotNetNuke is a popular one these days and has a free version.