Asp.net Dynamic page Creation issues - asp.net

I created a aspx blog website which creates page dynamically.
and uses unique id generated at the time of page creation as it's name.
eg:
http://www.websitename.com/2016/f1.aspx
http://www.websitename.com/2016/f2.aspx
http://www.websitename.com/2016/f3.aspx
If i use this naming convention, do i have to worry about SEO problems?
whether the the search engines index my website and the blogs?
I need to change the dynamically created page name to the page title. How can i do it?
and also i need to remove the .aspx from the blog page.
eg :
/f1.aspx => /HelloWorld
/f2.aspx => /ThisCode

Try this... although i didn't tried it myself yet... but i am pretty sure ..it should work... Add these lines in your webconfig to remove .aspx extension from the end...
<configuration>
<system.webserver>
<rewrite>
<rules>
<rule name="RemoveASPX" enabled="true" stopProcessing="true">
<match url="(.*)\.aspx" />
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="AddASPX" enabled="true">
<match url=".*" negate="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
</conditions>
<action type="Rewrite" url="{R:0}.aspx" />
</rule>
</rules>
</rewrite>
</system.webserver>

Try these links.... these might come handy
how to change title of aspx page dynamically on page load
Page.Title vs Title tag in asp.net
how can i create a dynamic page in asp.net (C#)?

Related

How to Hide any page extension like (.aspx and .asp and .php and .html) in asp.net IIS7

I have a requirement to hide any type of page extension in my site which have hosted 100 more page asp,html and aspx pages.
I want to hide all type page extension . I use following code which only works for .aspx. not work on .html & .asp page extension
<rule name="RemoveASPX" enabled="true" stopProcessing="true">
<match url="(.*)\.aspx" />
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="AddASPX" enabled="true">
<match url=".*" negate="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
</conditions>
<action type="Rewrite" url="{R:0}.aspx" />
</rule>
<match url="(.*)\.(aspx|php|html)" />
<action type="Rewrite" url="{R:0}.{R:1}" />
You can change regex of the match element so it matches on the other extensions.
You can (and should) use the routing mechanism provided by Asp.NET, in your specific case the MapPageRoute method as described here: http://msdn.microsoft.com/en-us/library/vstudio/dd329551%28v=vs.100%29.aspx
What you see about aspx pages can be applied to other kind of pages too, like plain html or old asp.

No .aspx page suffix, how come?

How come stackoverflow hasn't any .aspx page suffix in the url bar? Everything ends up in /something/ or /page
How can I achieve the same in asp.net?
Instead of webforms (and aspx pages) you could use MVC and it's routing feature (see http://www.asp.net/mvc/overview/controllers-and-routing) where a url is mapped to an "action" in a "controller".
A URL of /questions/25364620/whatever could be mapped to the "Index" action (a default value) of the "QuestionsController" ("questions" from the URL + "Controller"), with an id parameter of 25364620. The title is ignored.
These are called the friendly urls. I am not sure about how they have written in Stackoverflow but you can remove the .aspx entension by doing like this:
<rewrite>
<rules>
<rule name="RewriteMyASPX">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.aspx" />
</rule>
</rules>
</rewrite>

Changing the URL Extension

I had developed a Web application in Asp.net. When am using the Application over IIS, the file extension as.aspx is visible. Is it possible to hide it (or) rename it....Thankx in advance.
For .NET framework 4.0+, try the following rule in web.config (inside <system.webServer>):
The first will redirect URLs using the old format, to remove the .aspx extensions. You should of course update your links as well - eventually you won't need this.
The second rule rewrites URLs internally to add .aspx behind the scenes.
<rewrite>
<rules>
<rule name="RedirectOldFormat" enabled="true" stopProcessing="true">
<match url="(.*)\.aspx" />
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="InternallyAddAspx" enabled="true">
<match url=".*" negate="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
</conditions>
<action type="Rewrite" url="{R:0}.aspx" />
</rule>
</rules>
</rewrite>
For .NET Framework 3.5 or earlier, you can accomplish this using routing. Try the following solution:
http://www.codedigest.com/Articles/ASPNET/294_Search_Engine_Friendly_URLs_Using_Routing_in_ASPNet_35.aspx

Telerik RADEditor Failing to render with IIS Url Rewrite

am using IIS Url Rewrite to create friendly url, i have noticed after enabling it the radeditor fail to render as in the image :http://i.stack.imgur.com/TZo2O.png
The rule am using look like this in web.config :
<rewrite>
<rules>
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
<match url="^([^/]+)/?$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="Default.aspx?name={R:1}" />
</rule>
</rules>
</rewrite>
I have changed DialogHandler from aspx to axd and also changed the path for it to look like below and also cant render properly
<add path="~/Telerik.Web.UI.DialogHandler.axd" type="Telerik.Web.UI.DialogHandler" verb="*" validate="false" />
I examined the provided screenshot and noticed that the problem is that RadEditor does not load its CSS classes for its toolbar.
Try to register the skin by enabling the CDN stylesheet or manually as shown in this article: Registering an external skin of RadEditor.

Adding ignore case in URL rewriting in ASP.Net

I am using following web.config entry for url rewriting to remove .aspx extension.
<rewrite url="~/(.+)" to="~/$1.aspx" />
The problem I am getting here is if I have any image on page, it assigns .aspx extension to image.
Also if I tried to access my site like http://exmaple.com, it get redirected to http://exmaple.com/default.aspx.aspx.
I want to know if there is any way to add ignore case in web.config.
Your rewrite should look something like this, to remove .aspx
<rewrite>
<rules>
<rule name="RewriteASPX">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.aspx" />
</rule>
</rules>
</rewrite>

Resources