Is there a stable ASP.NET blogging control (designed for integration within existing site)? [closed]

末鹿安然 提交于 2019-12-04 13:42:26

问题


I saw dotnetblogengine.net and from forum posts I got the impression that it's not so easy to integrate it into existing site. Is there a modern blogging/news solution which is meant to be used just like any other ASP.NET control?


回答1:


Please find the step by step guide how to integrate this existing application. Moreover also you find the solutions to integrate with asp.net application as there is some complexities involved in integrating this BlogEngine web site project with asp.net web application. You can just follow below instruction then it is done.

Get the web project folder

Now that you have a downloaded zip file, you need to un-zip it. This can be done with a bunch of different utilities and in a bunch of different methods.

If you choose the Web Project download, your newly unzipped folder contains the web project you want to work with. If you download the source code, the web project is buried a little bit. The web project is found under the BlogEngine.NET folder, then the BlogEngine folder.

Load the web project on your web server

Now that you have the web project folder, copy those files and folders out to your web server. This usually involves FTP, but depending on your situation, it might even require a portable storage device (e.g. USB flash drive).

Set folder as a .NET 4.0 application

There isn't much to say about this. If you have direct IIS access, you need to create an application. If you are using a hosted provider, you need to use their control panel to make this happen. It should be a standard option, but if you don't find it, you may need to contact your hosting provider for support.

Add write permissions for App_Data folder

This is an often forgotten step. If you miss it, you'll notice as soon as you try to make a change. You need to give the application write permissions to the App_Data folder. Again, your hosting provider may have a control panel that allows you to do this. If not, you may need to contact your hosting provider for support.

Setting write permissions could involve up to 3 steps:

  1. Using the IIS admin tool or your hosting provider's control panel, set the folder as "Write" capable;

  2. If you have direct access to the file system, make sure the account under which the BlogEngine.NET's application pool is running (typically "ASPNET" on XP / 2003 and "Network Service" on Vista / 2008) has write access to the physical folder;

  3. After unzipping the web folder, all files have their read-only attribute enabled. Turn that attribute off for the App_Data folder and all files and sub-folders.

Navigate to the web page

Ok, now you are ready to navigate to the web site and see how you did. For example, if you installed the web site to your local machine for testing, you would navigate to http://localhost/default.aspx. You can also edit the default document to display to default.aspx using the IIS MMC snap-in. If you do this, you can navigate directly to http://localhost/ without specifying the page name. If all goes well, you are greeted by the default blog page.

Login and Setup your user name

The last step is to scroll down and find the sign in link on the right side. Click Sign in and then login in the following information.

User Name: admin
Password: admin

Once you login, you will see a new menu on the right hand side. Click Users.

Create a new user for yourself. The user name you choose is your display name. See the User Administration page for more information.

Delete the admin account. You don't want everyone who reads this to be able to login to your blog, do you?

Finally, log out, then log back in using the user account you just created for yourself.

The above installation is for, if we want to run the blog as a stand alone site which is rare specially in our case, **so lets include our blog within our site so that we will not have to redirect to another site to just go to the Blog or from blog to the main web site.**enter code here

Include the Blog Engine site to our own Project:

  1. Create a folder inside root named Blog or as you want to name it. Copy the whole Blog Engine .net site inside this folder except App_Global Resources,App_Code,Web.Config, robots.txt, web.sitemap and Global.asax.

  2. Rename the App_Code folder to BlogApp_Core or as you want. Because App_Code folders will not work with web application as they work with the web sites. Now Copy this folder to the Root of the project.

  3. Merge or Copy the App_Global Resources robots.txt and web.sitemap to the Root of the project.

  4. Add the Blog Engine.core project in the Web Application. Build Blog Engine.core and add reference from your web project to “BlogEngine.Core.dll”.

  5. Web.Config Changes If you already have a web.config in place then merge the Blog's Web.Config with it otherwise just copy it to the root. Go to the line in pages section:

change that to:

<add assembly=”BlogWap” namespace=”Controls” tagPrefix=”blog”/> 

where BlogWap is the Web Project Name. Go to the line:

<add key="BlogEngine.VirtualPath" value="~/" />

change this to:

<add key="BlogEngine.VirtualPath" value="~/Blog/" />

where Blog is the Folder name that we have created earlier.

If you want to use SQL As database we have to go for some more changes

Changes for using SQL as DB

Execute the Setup inside setup/SQLServer at your Sql to automatically generate the Tables. If you want to use ASP.NET Membership then you can delete the be.Users and be.roles tables.

Change the connection sting according to your DB where name="BlogEngine". Change the line:

<blogProvider defaultProvider="XMLBlogProvider">

to:

<blogProvider defaultProvider="DbBlogProvider">

Change the line:

<membership defaultProvider="XMLMembershipProvider">

to:

<membership defaultProvider="SqlMembershipProvider">

Change the line:

<roleManager defaultProvider="XMLRoleProvider" enabled="true" cacheRolesInCookie="true"> 

to:

<roleManager defaultProvider="SqlRoleProvider" enabled="true" cacheRolesInCookie="true">
  1. Right Click on the Project and click on Convert to Web Application.

now you will think we are done with the web site to web applicatication conversion but wait there is some issues with the Blog Engine .NET 2.0 version while including it inside our project now we have to edit the Files inside the project to get it work.

  1. Search for ~/admin at web project level and replace it with ~/Blog/admin Blog is our folder name.

  2. And same for ~/widget ~/themes and ~/pics.

  3. Open the file ~/blog/pages/settings.aspx.cs and go to line 262 in method BindCultures() and change the following line from:

    string path = Server.MapPath(Util.AbsoluteWebRoot + "App_GlobalResources/");

to:

string path = Server.MapPath("~/App_GlobalResources/");
  1. Open the BlogEngine.Core project and go to the Utils.cs. Now search for CodeAssemblies() function here we need to change the assmebly:

    var assemblyName = "__code";

Change this line to:

var assemblyName = "WebProjectName";

and:

else
{
    if (!IsMono)
    {
        assemblyName = "App_Code";
    }

to:

else
{
    if (!IsMono)
    {
        assemblyName = "WebProjectName";
    }

Go to the function :

AddFolderJavaScripts()

Change

var fileEntries = Directory.GetFiles(HostingEnvironment.MapPath("~/" + pathFromRoot))
    .Where(file =>
        !scriptsAddedDuringRequest.ContainsKey(file) &&
        file.EndsWith(".js", StringComparison.OrdinalIgnoreCase) &&
        !file.EndsWith("-vsdoc.js",                
    StringComparison.OrdinalIgnoreCase)).ToList();

to:

var fileEntries = Directory.GetFiles(HostingEnvironment.MapPath("~/Blog/" + pathFromRoot))
    .Where(file =>
        !scriptsAddedDuringRequest.ContainsKey(file) &&
        file.EndsWith(".js", StringComparison.OrdinalIgnoreCase) &&
        !file.EndsWith("-vsdoc.js", 
    StringComparison.OrdinalIgnoreCase)).ToList();
  1. Now Check the files inside Blog/admin folder here you have to check for the namespace actually they have messed up the namespace may be it will be fine in the further releases. You have to also check for the Case of the letter like Admin and admin. Fix all the name space problem.

  2. Do a global Search for ~/App_Code and replace it with ~/Blog_App_Code or whatever you have named your App_code Folder.

  3. Build the project and Run now your application should work fine go to Blog Try to add Blogs Delete Blogs wait hey what happened you can not delete the blogs ohhh My God what is going wrong hmm so searching for a solution and finally got the problem :).

So here is the solution. Actually deletion is through asmx which we are calling internally from js so we will have to check the path inside js file that, it is having the correct path to the asmx files or not, the best way is to add the following lines to your site.master and admin.master

<script type="text/javascript">
    var fullBaseUrl = '<%=ResolveUrl("~") %>';
</script>

and use this fullBaseUrl variable inside your admin.js file which was having problem. And we also have to add the following 2 lines to the Web.config under handlers section to make these asmx files to work:

<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

Now it is time for checking that every thing is working fine or not so go ahead build the project and browse wow its working fine awesome finally we did it, but after a rigorous testing got to know that, still we are having some issues which I got after a long gap :( and this was with the media files as we can see we are having option to upload video files to the posts and pages the upload will work fine but when you will go to that post there will be no video just a black box ohh again I am stuckkkk but hey we are software engineers never get scared of a problem just have the confidence in yourself and go ahead,so lets explore and as we know if there is problem there is a solution :) oh wow got the solution

Go to Blog/admin/EditPage.aspx.cs ohh they have hard-coded the path here, so that was the problem

Search for the function:

BtnUploadVideoClick(object sender, EventArgs e)

Change:

var folder = "~/" + mediaFolder + "/";` to `var folder = "~/Blog/" + mediaFolder + "/";

We have to do the same once again for post and you will find this inside Blog/admin/post/Add_entry.aspx.cs in BtnUploadVideoClick(object sender, EventArgs e) {

Build the solution again and browse Hey finally we got our Blog running perfectly :)

We can also add Facebook and twitter for sharing the post through twitter and facebook I have just attached one file to our BlogApp_Code/Extensions folder to implement this functionality, after that built the project, browsed it, and the magic is there when we will go to your post we will get facebook and twitter share option just below your post. We can also create our own theme in Blog Engine .net by just following some rules. So congrats we are done with the integration of BlogEngine.net inside our web site with visuals similar to our site. Now upload post add pages to the Blog share your thoughts use Blog for your business and have fun do what ever you want :).

Conclusions

AS an ASP.NET Developer Blog engine .NET is the best Open Source Blogging tool with few minutes easy installation.Play With the Code and make it work according to your requirements. Just need to take care of some points to make it work inside our project.

Bibliography

  • http://www.upfromthesky.com/blog/post/2009/01/30/Integrate-BlogEngine-145-into-an-exisitng-website-%28VSNET-Website-Project%29.aspx
  • http://blogengine.codeplex.com/documentation

Refer these sites for customization. For creating our own themes:

  • http://blogengine.codeplex.com/wikipage?title=ThemeCreation

For Creating our own Extensions:

  • http://blogengine.codeplex.com/wikipage?title=Extensions&referringTitle=Documentation

For Creating Our own Control:

  • http://blogengine.codeplex.com/wikipage?title=CreateNewControls&referringTitle=Documentation



回答2:


Dasblog on codeplex is easily integrated. Scott Hanselman actually uses it for his blog http://www.hanselman.com/blog

http://dasblog.codeplex.com/




回答3:


Best bet with BlogEngine is to set it up as a sub-domain of your existing site and re-skin the CSS to match your existing design. Here's an example of where I used that approach:

http://homenetdirect.com

http://blog.homenetdirect.com/

A blog has just too much to it to be implemented as a control IMHO. However, you could easily create an admin for a simple news panel with title and date on top and database it.




回答4:


BlogEngindotnet is so much easy to build your blog, you just need to

  1. download the latest version ,
  2. run the database script available in source code,
  3. change connection string pointing to database,
  4. upload on subdomain, that's it!

If you need free blogging then use blogger provided by google.



来源:https://stackoverflow.com/questions/7697748/is-there-a-stable-asp-net-blogging-control-designed-for-integration-within-exis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!