How To Use Intelligencia.UrlRewriter
Nov 19, 2010
I'm trying to use theIntelligencia.UrlRewriter that Scott Gu wrote about and another guy located ehere: [URL] Some info about my app: I have a master page with a menu populated via dataset. Users add pages to the site and store them in the database. One table for the page and another for the content. When the user selects a page in the menu control I redirect them to the default.aspx page which is a child of the masterpage. This works great.
Protected Sub Menu1_MenuItemClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs) Handles Menu1.MenuItemClick
Response.Redirect("default.aspx?PageName=" + HttpUtility.UrlEncode(Menu1.SelectedItem.Text))
End Sub
On the Default.aspx page I get the page content with this:
Protected sub Page_Load(ByVal sender
As
Object,
ByVal e
As System.EventArgs)
Handles
Me.LoadIf
Not IsPostBack
Then
Try
If
Me.Request.QueryString("PageName") <>
Nothing
Then
divContent.InnerHtml = PageContent.Get_PageContentData(PageName)
GetControls(PageName)
Dim PageName
As
String = HttpUtility.UrlDecode(Request.QueryString("PageName"))Dim
PageContent As
New PagesElse
divContent.InnerHtml = PageContent.Get_PageContentData(
GetControls(
Dim PageContent
As
New Pages"Home")"Home")End
If
Catch ex
As ExceptionEnd
Try
End
If
End
Sub
EVERYTHING works with this except I'm left with a URL like this: [URL] I would like it to look like this:[URL] But only after I get the page content populate the page! How would I use the Intelligencia.UrlRewriter in this situation?
View 1 Replies
Aug 30, 2010
I have implemented a URL rewriting(extensionless) using Intelligencia.UrlRewriter, it works perfectly on my PC but on the server I am getting the following error Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. also make sure that System.Web.SessionStateModule or a custom session state module is included in the <configuration><system.web><httpModules> section in the application configuration. this is my web.config file
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="rewriter" requirePermission="false"
type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<appSettings>
</appSettings>
<system.web>
<!--
Set compilation debug="true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
</compilation>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-GB"/>
<!--
The <authentication> section enables configuration of the security authentication mode used by ASP.NET to identify an incoming user.
-->
<authentication mode="Forms">
<forms loginUrl="/Admin/Login.aspx" name="FormAuthentication"></forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<!--
The <customErrors> section enables configuration of what to do if/when an unhandled error occurs during the execution of a request. Specifically, it enables developers to configure html error pages to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="admin/Error.aspx" />
<error statusCode="404" redirect="admin/Error.aspx" />
</customErrors>-->
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
</pages>
<httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<remove name="ScriptModule"/>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
</modules>
<handlers>
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory"/>
<remove name="ScriptHandlerFactoryAppServices"/>
<remove name="ScriptResource"/>
<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"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v2.0.50727"><dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding></runtime>
<rewriter>
<rewrite url="~/([0-9]*)/.*" to="~/custompage.aspx?Id=$1" />
</rewriter>
</configuration>
this is the error's stack trace
[HttpException (0x80004005): Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <configuration><system.web><httpModules> section in the application configuration.]
System.Web.UI.Page.get_Session() +2647836
System.Web.UI.UserControl.get_Session() +17
MmmarvellousWebSite.userControls.WebSite.VerticalMenu.Page_Load(Object sender, EventArgs e) in C:Documents and SettingsGiga GigaprMy DocumentsVisual Studio 2010ProjectsMmmarvellousWebSiteMmmarvellousWebSiteuserControlsWebSiteVerticalMenu.ascx.cs:10
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
View 2 Replies
Apr 27, 2010
i am using Intelligencia.UrlRewriter on my website and it works fine on my development machine, i tryed to deploy on IIS6 and i get this error:
The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.Please try the following: Make sure that the Web site address displayed in the address bar of your browser is spelled and formatted correctly. If you reached this page by clicking a link, contact the Web site administrator to alert them that the link is incorrectly formatted. Click the Back button to try another link. HTTP Error 404 - File or directory not found.
Internet Information Services (IIS)
Technical Information (for support personnel)
Go to Microsoft Product Support Services and perform a title search for the words HTTP and 404. Open IIS Help, which is accessible in IIS Manager (inetmgr), and search for topics titled Web Site Setup, Common Administrative Tasks, and About Custom Error Messages. this is the url that throws the error. [URL] this is the working url that is being rewriten to the above one. [URL]
View 2 Replies
Nov 10, 2010
I am using the ajax slideshow which retrives an Image URL from my database table/ It works fine but as soon as I started using the Intelligencia.UrlRewriter, images are not showing. all my code is below.
Code Behind
private static DataTable tblData = new DataTable();
string sName = Request.QueryString["Id"];
<query string param is UserId>
string strSQL = "SELECT [ImageUrl],[FirstName], [LastName] FROM [Images] WHERE ([FootballerId] = @FootballerId)";
SqlConnection conn = new SqlConnection("Data Source=xxxxxxxxxxxxxxxxxx");
conn.Open();
SqlCommand comm = new SqlCommand(strSQL, conn);
comm.Parameters.Add("@FootballerId", SqlDbType.NVarChar).Value = sName;
SqlDataAdapter da = new SqlDataAdapter(comm);
tblData = new DataTable();
da.Fill(tblData);
conn.Close();
// set the initial image
if (tblData.Rows.Count > 0)
{
imgShowImage.ImageUrl = tblData.Rows[0]["ImageUrl"].ToString();
imageLabel1.Text = tblData.Rows[0]["FirstName"].ToString();
}
}
}
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static AjaxControlToolkit.Slide[] GetSlides()
{
AjaxControlToolkit.Slide[] slides = new AjaxControlToolkit.Slide[tblData.Rows.Count];
for (int i = 0; i < tblData.Rows.Count; i++)
{
DataRow dr = tblData.Rows[i];
slides[i] = new AjaxControlToolkit.Slide(
dr["ImageUrl"].ToString(),
dr["FirstName"].ToString(),
dr["LastName"].ToString());
}
return slides;
}
ASPX
<cc1:SlideShowExtender
ID="slideshowextend1"
TargetControlID="imgShowImage"
SlideShowServiceMethod="GetSlides"
AutoPlay="true"
ImageDescriptionLabelID="imageLabel1"
NextButtonID="nextButton"
PlayButtonText="Play"
StopButtonText="Stop"
PreviousButtonID="prevButton"
PlayButtonID="playButton"
Loop="true"
runat="server"
Enabled="True">
</cc1:SlideShowExtender>
<div
class="GridRight">
<asp:Image
ID="imgShowImage"
runat="server"
Height="300px"
ImageAlign="Middle"
/>
</div>
SQL Database Path
/Footballer/sandra//Horses.jpg
Web Config
<rewriter>
<rewrite url="~/Sandra" to="~/CMC/PublicProfile.aspx?Id=dff12c6b-e37c-4591-97ae-a65c27c1de1d"/>
</rewriter>
rewriter>
<
View 2 Replies
Mar 17, 2011
Im using Intelligencia UrlRewriter for url rewriting. I have wrote a set of rules in the web.config file I have two sets pages, Static pages whose name is static but content is CMS based Dynamic pages (actually this is not simply a dynamic page its a category which have description and sub categories) Here both pages are being rewritten from the config file. For instance home page, about us page etc tis is being rewritten as
rewrite url="~/Home" to="~/Default.aspx"
The category page is being the same kind of url its being rewritten as
rewrite url="~/(.*)" to="~/GroupHome.aspx?Group=$1"
I have given the rules for the static pages first and then the category url but all the urls are being rewritten to grouphome, even if I have given the rule for home page, about us page etc before the category rule. I have tried even the ollowing still its directing to Group home,
<rewrite url="~/Home" to="~/Default.aspx"/>
<rewrite url="~/(.*)/" to="~/GroupHome.aspx?Group=$1"/>
<rewrite url="~/Home" to="~/Default.aspx"/>
How the rule can be rewritten to include both urls
View 1 Replies
Mar 12, 2010
can i register a debug logger that outputs information to the 'standard ASP.NET debug window'. My problem is I don't know what that means, if it means the debug output window in Visual Studio (where you see build output, debug output and more) I am not seeing any UrlRewriter debug output. The rules are working (mostly) I just want to get more debug output to fix issues. I added the register call to the rewriter section like this:
<rewriter>
<register logger="Intelligencia.UrlRewriter.Logging.DebugLogger, Intelligencia.UrlRewriter" />
....
</rewriter>
I am hosting this website locally in IIS on Vista, to debug it I attach the debugger to the w3wp process. Other selected parts from the web.config"
<compilation debug="true">
<assemblies>
...
</assemblies>
</compilation>
<trace enabled="true"/>
Where should I see the debug output from UrlRewriter.NET? If it is in the Visual Studio debug output window, any ideas why I am not seeing it there?
View 2 Replies
May 3, 2010
I'm having some problems with the module urlrewriter.net for ASP.NET.I have a multilingual site with a URL like this;
~/home.aspx
To support languages I use this rewrite rule;
<rewrite url="~/de-DE/(.*)" to="~/$1"></rewrite>
Then in my code I get the de-DE part and set the right culture for the current thread. All of this works well.After I login on the website I get a message "Hello, user x" to show i'm logged in. When navigating to another page, it doesn't display this message anymore and it seems like the page comes from the cache or something with the old (not logged in) data. Also, when I attach the debugger, nothing is executed for this request. If I visit the page like ~/home.aspx instead of ~/de-DE/home.aspx, does problem does not occur.
View 1 Replies
Nov 3, 2010
I'm using UrlRewriter.net, mentioned on ScottGu's Blog. I've built a site around this and now I'm having problems with subdirectories. The problem is, I want to exclude a directory and all subdirectories/files within it from rewriting. The rules I have are:
<rewrite url="~/(.*)/Uploads/Images/(.+)?" to="~/Uploads/Images/$2" processing="stop" />
<rewrite url="~/(.*)/Uploads/(.+)/(.+)?" to="~/Uploads/$2/$3" processing="stop" />
<rewrite url="~/(.*)/Uploads/(.+)?" to="~/Uploads/$2" />
The problem is, although I can access files in the uploads directory (/Uploads/myfile.ext) and see the directory lists for direct subdirectories (/Uploads/mySubdirectory/), anything in /Uploads/mySubdirectory/, eg: /Uploads/mySubdirectory/myfile.ext returns a 404, because the UrlRewriter is messing with the Urls. I've tried these rules in different orders to no avail.Has anyone used this before? There must be a way to get it to work.
View 1 Replies