How to create a blog site in asp net c

Introduction and background I don’t want to talk too much in this article, I just want to demonstrate the presentation I have to do today. This article is a short “extensive report” that can be considered as an answer to the most common question: “How to create a blog in ASP.NET?” Well, I It seems more convincing that most people are unaware of what a blog itself is, because if they knew they could play around with ASP.NET to create one of their own in an evening or two. In this article, I will discuss a few steps to take when creating your own blog. I’m not a good designer, so forgive the more annoying design you’ll see in the next few sections. But I promise I’ll give you an overview of a “ASP.NET blog“. The facts I’m going to talk about, or the reason you should read this article, is that this article is not a “specific” how-to for my own procedures. Instead, I am writing this article to give you a brief overview of what a blog is, what ASP.NET has in store for you, how you can create it, and not only that, but also how you can create a blog with all you have. In most cases, you only have a small area to host with less hard drive space and no database. I will cover what to do in such cases as well. Just read the post. To add some “content“, I wrote a Windows 10 client app to consume the blog posts via the ASP.NET Web API. I’m sure in most cases this Web API for ASP.NET Blog Posts thing will interest you. what you want, when you want, with whom you want! That is a general type of blog that is used. Blog is short for weblog (log, does that make sense?). More specific types of blogs come depending on their content. Some of the categories of blogs are as follows:

  1. Microblogging Compact and simple blogs. The 140-character beast, Twitter, is one such example.
  2. Personal blogs Anyone can create them, and they’re very personal, featuring just one person. Your website can be your personal blog.
  3. Media blogs You can share images, videos, and other multimedia content on media blogs.

So basically a blog is just a website to share the content. If you’ve ever created an online website to share content, current job information, regular “daily“, then you’ve already worked on developing a personal blog. Blog is just a term given to the online registration system, where you can “register” your regular discussion topics. So, in this article post, I am going to cover a basic application that can act as a blog for someone. As additional support, I’ll also give you an idea of ​​how to use the ASP.NET Web API to promote your blog in native apps, such as a native Windows 10 app that loads your single blog content and displays blog posts to users. users natively. Getting started with ASP.NET Since most readers are currently not upgrading to ASP.NET MVC 6, I’ll use ASP.NET MVC 5 (not ASP.NET 5) to show you how to do it. Things are very similar in ASP.NET MVC 5 and ASP.NET MVC 6. The common things I have found that change in the next few versions is that ASP.NET is now cross-platform so if you continue to write the same thing by following my article , in ASP.NET MVC 6, you will be able to run it on a server on Ubuntu or Mac and so on. But that’s not a big deal here, is it? I’ll be using ASP.NET MVC 5 (not ASP.NET 5!) to demonstrate how to create your own personal ASP.NET blog. But before I get started with Visual Studio, I wanted to explain the term “customizable“, which is used in the title of my current article. By the term “customizable” I mean,

  1. A blog that is completely flexible. You can integrate plugins or update the theme etc.
  2. A blog that is not based on a specific external framework or even a data source.
  3. A blog that is built right on top of ASP.NET assemblies and doesn’t require you to do anything at all.
  4. A general blogging platform, which can then be modified to create,
    1. Social blogging service.
    2. Personal CV House
    3. Your own website to demonstrate your services
    4. And so on.

In simple, the blog can be modified according to your own needs and requirements. After all, an ASP.NET blog is just an ASP.NET Web application that you’ve modified to suit your own needs. At this stage I would ask you to create a new ASP.NET project on your own machine, in the next section I will continue with the following things like creating controllers, defining the Views etc. So it would be good if you created a new project at this point and continue to the next article.Building the ApplicationFirst, I’d like to share how I built the ASP.NET web application to host my blog. I am going to use a web interface and an API interface, to be able to consume the blog from multiple native applications. So, I’ll talk about ASP.NET programming in this section, and then I’ll talk about programming Windows 10 apps, to consume blog posts and display them to users in a “native experience”.Web Interface ControllerFirst, I will consider creating the web interface to be able to display the blog on the Internet, using a browser.This is what ASP.NET was originally developed for.To build websites and web applications Web applications were introduced a bit later and then Web API was introduced and so on, so I’m going to use the very basics of ASP.NET MVC to create a simple web application that can “act strong>” as a blog. If you are a newbie to ASP.NET, because most of the time the question (in the title) is asked by a newbie to ASP.NET, so if you have no idea about ASP.NET Please read my previous posts that cover ASP.NET in great detail. They would help you understand and learn every part of ASP.NET programming, from a beginner’s perspective.

  1. Understanding ASP.NET MVC using a real-world example, for beginners and intermediates .
  2. New to MVC? Please read this (ASP.NET MVC is an implementation of the MVC software development pattern, this post talks about MVC, not ASP.NET MVC).
See Also:  How to create a website using drupal 8 step-by-step pdf

I will keep sharing more of my articles and posts, as the topic progresses. I would recommend you to read the above posts if you are new to ASP.NET, most of the concepts like Controller, Views and Models can cause you confusion, if you are a newbie. Almost there I’m a huge fan of JSON data, I prefer using JSON over SQL databases, and therefore I’m a fan of the Newtonsoft.Json library. Therefore, consider installing the library before proceeding. This library would be the backbone of our data source.PM> Install-Package Newtonsoft.Json -Version 7.0.1Once this package is installed, continue to the next section.1. Build the model for the appIn my case, I always prefer to build the models first. This gives me an idea of ​​how to build the controllers and then build the views for the app. So, I would also give you some advice, to always build the models, the data structures first, and then continue building the rest of the stuff. The template we need is just a template for the blog post. So the structure would be as simple as this:

In the model, I have the following attributes that can be used to identify or describe the blog post in the instance.

  1. ID
  2. Title
  3. Content
  4. Labels (is an array; List)
  5. CreateTime (used to sort the elements)

Great, now we have a model and now we can continue writing the rest of the logic for our application. The model implements the CRUD functions, which we can call from external objects, both from the web interface and from the Web API interface. This would allow us to manage the data layer in this class.2. Creating the controllerOkay, first of all, create the controller. The controller would have the actions we need to perform on our blog. Pay attention to the following code:

The above code is enough! This code contains the code you may be needing. Now, I think I need to explain the code a bit. I have implemented the CRUD functions, in this way, I created the functions that would allow me to create a new post, read the list of posts, read a single post on the web page, or perform other functions such as updating the post. You can also see that most of the code and functions are called from the model. Therefore, I designed the model before creating the controller. I think you now understand the importance of a model before the controller. The controller would simply catch the request, extract the data from it, and then pass the data and the request to the Model. The model would then work on our request and return a response, which can then be sent back to the client. The purpose of such a design is to create a web application that is also consumed by the web API. In later sections I will consider sharing that as well. So far, the web application can show us posts on the blog. If we have created a post, it will show us the post; otherwise, it will show us a message that there are no posts currently available.3. Creating the ViewsViews are simple enough to be easily understood! If you’ve been developing using HTML, I won’t explain them. If you haven’t, learn! Default PageThe default page for the blog would be simple, include the blog posts, or display a message.For this page, I would show the HTML code, and for the rest of the pages I’ll show the images, because I want to demonstrate how to use the actions. The page uses the conditional values ​​of the controller. You may have noticed the value of Controller, which is passed as a model (of type BlogPostModel). I have checked to see if there are any posts in the data source. That’s pretty simple and straightforward. The main thing to see, if what happens if there is a new publication in the data source. Consider the next section, please! Create the postWhen you create a new post, you follow the hyperlink, which takes you to a page where you’ve created a form, and so on. I’m not a designer type so the UI is very ugly. You can improve it if you want. The “C” view in “CRUD, looks something like this. It’s very simple though, but powerful! The power is in your hands. Add some or leave them if you don’t want to share the dashboard admin with no one. 🙂 Once this page loads, it takes the following web page form.Figure 1: Create a new blog post page.The form is populated The HTML above takes this form.The HTML looks clean thanks to the hard work of:

  1. The ASP.NET team for providing a template.
  2. Bootstrap friends, Twitter Bootstrap is used here ( is provided along with the ASP.NET template).
See Also:  How to Connect a Printer to Your Computer

Now you can submit the post. Okay, so far things are pretty clear and simple. Do you have any questions? Come back to read this section.Checking the default page nowIf you go back to the default page now, you will see that the blog will now include the posts (currently only 1).L The following is the image, it already has the HTML for this page.Figure 2: Default page showing a blog in the list Now the page can show that we have a post, it shows the tags and name. Nothing else. After all, why would we display anything else on the default page? Read the blog posts, one by oneIf you could read the HTML of the default page, you’ll see that the title of the blog post blog is actually a URL of the blog post, to be read. I created the action for that (read the controller code for the read action). This would now allow us to read the content, Figure 3: Read Post, displays the date, time, content, and tagsThis is how I display the content. I agree, a very bad design. But I am very bad at designing web applications. (I know, my first attempt went wrong because the ids were null and Oh, you got it the second time, didn’t you? Stop whining!). I used the following HTML code for this, the point was that I just wanted to display the blog post, in a very simple way. In fact, in your case, you will write something much more useful. But for now, just read this.

So this code would give us the post. I have a lot of things coded, like “Posted by — Afzaal Ahmad Zeeshan & mdash; on {date and time}.” You can change it, see who the author is, etc. There are plenty of other things to take care of. One thing you need to understand is that your HTML is not the same as what is saved in the data source. So you may need to reconsider the HTML and then render it using the Html.Raw function. Take a look at the following code, for example, now each occurrence of “
” would be replaced with the breakline object in HTML. This way, you can rebuild the HTML and display it as plain text in the HTML web page.Updating PostsThe final concept I’ll talk about here would be updating posts. Updating is similar to creating the new post, only that it also provides the old data it has. The title, content and other things can be provided and then the user can update them as needed and then save it to the data source. I’ve used the same HTML form in this case, this is similar to what we had before. But it is rendered alongside the previous data we had.Figure 4: HTML page showing the form for editing the previously updated post. As you can see, the post contains the old data, but it also allows me to update the post. This is useful, in cases where you want to update the post. I am adding a new paragraph line, which will then render as it is typed. Tip: This is not a WYSIWYG editor, just a plain text area. You should get a WYSIWYG editor if you want to be able to use the full power of HTML in your post. Now once you submit this, it will be published as this version. Review controller action. This demonstrates how you will update the post. Once again, we are using the PostManager, the object that we created in our model in order to perform the actions. The post is now up to date, take a look at the post preview review. Figure 5: Updated Post Preview Now shows the updates that are being made. It’s also clear how the newline is added to the post.It was pretty simple, but I also wanted to demonstrate the concept of this.Adding New PostsOne more thing is adding new posts. This is the same thing, it requires only one view. I’m about to give you an overview of how to add new posts, multiple posts, and how this previews them on the default page. Figure 6: Creating a new blog post, second This is similar, what The only thing to understand is how it is rendered on the blog.Figure 7: Previewing two postsWhat I wanted to share here is that ASP.NET will not automatically sort the posts, you would have to do it yourself If you pay attention to the LINQ code , you will understand. This would now sort the blogs, in descending order. That’s why “Two Posts” shows up above, whereas in the JSON data it would come after “First Blog Post!” But now we’ve sorted the list based on our requirements. Go to Windows 10 App and Web APIBefore I go, I want to make one final post that reads in the app. See the next image, then we continue to the next section.Figure 8: Final post onlineThe web interface has been discussed enough, the next sections will talk about the web API and Windows 10 application programming .Further reading:For more detailed information, please read the following documents and articles.

  1. A tip for ajax developers in the ASP.NET MVC framework
  2. Getting started with LINQ in C#
See Also:  How to create a website for real estate business

Web and client APIs Windows 10 appIn this section, I’ll first talk about the ASP.NET Web API, and then build the app to consume the API and display the blogs. In the client application, we don’t need any functions like create, update, etc. We only consume and display the data, so the client application will not have enough features but will display the content.Building the APIActually, the API is simple and you don’t need to do anything. The app is already complete, so our API would just redirect to the app and load the model data and return it. The API doesn’t need to have HTML data or CSS style sheets, instead the API just returns the data in JSON or XML format. I personally and will always recommend using JSON. XML is a very heavy format and it is also not efficient. JSON is a much simpler, lighter and more portable format! The API is just a controller, with the same actions we need and a return type. Since we don’t need any functions other than C (from CRUD), I defined the API to be as simple as,

Small, but enough. This would allow us to consume the API of our client application. There is also no need to edit the API configuration, as I have provided the routing scheme to the function. This would automatically route to this URL. The rest of the functionality must be provided by the application. One thing to note is that this function, again, reads the data from the model and returns it as a collection. This would then be translated as JSON data later. Then our app will be able to use the JSON converters to get the data from the API and render it in the app. I hope things for the API are clear up to this stage! If not, please read again. I think the post is pretty simple.Building the client application; Windows 10 ApplicationGreat, so far you have learned how to create an online blog that has a web interface and an API interface. I will continue with the next post, to teach you how to consume the API, the post has gone much longer than I expected (exceeded 4k words). Please read the article above and leave your comments, I’d love to hear it! Points of InterestThanks for reading the post, I have shared a common, yet easy and simple way to create your own blog. The post contains the information you may need to create your own personal blog online. I have not shared any 3rd party libraries because I want you to be able to add your own. The blog is built on native ASP.NET frameworks. In a later post, I’ll also share the common concepts for building the datasources, so that the single “Newtonsoft.Json” dependency is also removed from this project. Until then, bear with me. One more thing, the text editor used is a plain text area, you can replace it with your favorite WYSIWYG editor to be able to use the power of HTML, then display the HTML on the screen. In the next few days, I will write two more posts:

  1. Consuming the web API from the Windows 10 app.
  2. Creating your own custom data sources.

Stay tuned for more such content!

.

Leave a Reply

Your email address will not be published. Required fields are marked *