Error
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Forms/Blogs/4/Hist-of-East-Africa-.aspx
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4494.0
Imports System.Web.Routing
Imports Microsoft.AspNet.FriendlyUrls
Public Module RouteConfig
Sub RegisterRoutes(ByVal routes As RouteCollection)
Dim settings As FriendlyUrlSettings = New FriendlyUrlSettings()
settings.AutoRedirectMode = RedirectMode.Permanent
routes.EnableFriendlyUrls(settings)
End Sub
Sub RegisterRoutes2(routes As RouteCollection)
routes.MapPageRoute("DisplayBlog", "Blogs/{BlogId}/{Slug}.aspx", "~/Forms/DisplayBlog.aspx")
End Sub
End Module
global asax code
Imports System.Web.Optimization
Public Class Global_asax
Inherits HttpApplication
Sub Application_Start(sender As Object, e As EventArgs)
' Fires when the application is started
RouteConfig.RegisterRoutes(RouteTable.Routes)
BundleConfig.RegisterBundles(BundleTable.Bundles)
RouteConfig.RegisterRoutes2(RouteTable.Routes)
End Sub
End Class
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Defaultblog.aspx.vb" Inherits="OPAC.Defaultblog" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<h2>
Blogs</h2>
<br />
<asp:HyperLink ID="HyperLink1" NavigateUrl="~/Forms/AddBlog.aspx" Text="Add Blog" runat="server" />
<hr />
<asp:Repeater ID="rptPages" runat="server">
<ItemTemplate>
<%# Container.ItemIndex + 1 %>
<asp:HyperLink ID="HyperLink2" NavigateUrl='<%#String.Format("~/Blogs/{0}/{1}.aspx", Eval("BlogId"), Eval("Slug")) %>'
Text='<%# Eval("Title") %>' runat="server" />
</ItemTemplate>
<SeparatorTemplate>
<br />
</SeparatorTemplate>
</asp:Repeater>
</form>
</body>
</html>
Please help iam trying to open blogs but iam getting the error below
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="DisplayBlog.aspx.vb" Inherits="OPAC.DisplayBlog" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<h2>
<asp:Label ID="lblTitle" runat="server" /></h2>
<hr />
<asp:Label ID="lblBody" runat="server" />
</form>
</body>
</html>
display blog
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="DisplayBlog.aspx.vb" Inherits="OPAC.DisplayBlog" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<h2>
<asp:Label ID="lblTitle" runat="server" /></h2>
<hr />
<asp:Label ID="lblBody" runat="server" />
</form>
</body>
</html>
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
Public Class DisplayBlog
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Me.PopulateBlog()
End If
End Sub
Private Sub PopulateBlog()
Dim blogId As String = Me.Page.RouteData.Values("BlogId").ToString()
Dim query As String = "SELECT [Title], [Body] FROM [Blogs] WHERE [BlogId] = @BlogId"
Dim conString As String = ConfigurationManager.ConnectionStrings("SLISConnectionString").ConnectionString
Using con As New SqlConnection(conString)
Using cmd As New SqlCommand(query)
Using sda As New SqlDataAdapter()
cmd.Parameters.AddWithValue("@BlogId", blogId)
cmd.Connection = con
sda.SelectCommand = cmd
Using dt As New DataTable()
sda.Fill(dt)
lblTitle.Text = dt.Rows(0)("Title").ToString()
lblBody.Text = dt.Rows(0)("Body").ToString()
End Using
End Using
End Using
End Using
End Sub
End Class