CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 3/5/2008 1:50:54 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 7 Views: 56 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
8 Items, 1 Pages 1 |< << Go >> >|
PoulRaider
Asp.Net User
url rewriting3/5/2008 1:50:54 AM

0/0

 masterpage head section.

<head runat="server">
    <title>BorkedGuild.net Forum</title>
    <link href="~/css/forum.css" rel="stylesheet" type="text/css" runat="server" />
    <link href="~/css/TopLine.css" rel="stylesheet" type="text/css" runat="server" />
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>

I have then implemented a urlrewriter.

 

1            public void Init(HttpApplication context)
2            {
3                context.BeginRequest += new EventHandler(context_BeginRequest);
4            }
5            void context_BeginRequest(object sender, EventArgs e)
6            {
7               
8    
9             
10               HttpApplication app = (HttpApplication)sender;
11               Match oMatch = Utilities.rx.Match(app.Request.RawUrl.ToLower());
12               
13               if (oMatch.Success)
14               {
15                   string newUrl = Utilities.rx.Replace(app.Request.RawUrl.ToLower(), "/board/Default.aspx?f=$1");
16                   app.Context.RewritePath(newUrl,false);
17               }
18   
19           }
  What happens is that when i request an url that the oMatch does not success on. Then it only runs context_BeginRequest one time(http://localhost:49403/BorkedGuild.net/board/default.aspx?f=1). When I enter a url that my match find,(http://localhost:49403/BorkedGuild.net/board/1/) THen it first as expected does (have pasted the string it generate here) app.Context.RewritePath("BorkedGuild.net/board/default.aspx?f=1",false), but then with some breakpoints enabled, it pops again on line 6 two times where the
app.Request.RawUrl is equal to:
		RawUrl	"/BorkedGuild.net/board/1/BorkedGuild.net/css/forum.css"	string
  RawUrl "/BorkedGuild.net/board/1/BorkedGuild.net/css/TopLine.css" string
 which clearly is why my css is broken on the returned page.
 
Any comment on why its sending the request to the urlrewriter this second time for the css links but not the first time(based on when a not matched link is requested it do not hit the breakpoint at line 6 for the css links). 
r_nassabeh
Asp.Net User
Re: url rewriting3/5/2008 7:05:17 AM

0/0

When you open a page in the browser it may cause several Application_BeginRequests on the server. For example every linked css and image will cause another request so you must not rerwite just the first request. Your code must also match other requests and rewrite them as well.


Good Luck!

Reza Nassabeh


Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
tejasdesai
Asp.Net User
Re: url rewriting3/5/2008 8:45:11 AM

0/0

It seems currently Utilities.rx class is handling only your .aspx page and not the ascociated reources and hence for all other css file oMatch.Success is false.
You need to modify your Utilities.rx class to handle css files too and also you need to remove the hard coded path "/board/Default.aspx?f=$1" and make it dynamic depending on the RawUrl.

 Hope this helps you...


TEJAS DESAI
System Analyst
L10NBRIDGE
India
PoulRaider
Asp.Net User
Re: url rewriting3/5/2008 3:57:47 PM

0/0

Oki, thats what i missed then.

 

 public static Regex rx = new Regex("/board/([0-9]*)/*$", RegexOptions.Compiled | RegexOptions.IgnoreCase);

 

Gotta get that matching all other links also. I actuly belived the css/links and such was relative to the aspx page, aka doing app.Context.RewritePath(newUrl,false); it would fetch the links from that url instead.

Aint this url rewriting abit "expensive" then, if it on every request have to do some regex matching and such?

 Im not sure i understand why, after it did the rewritePath on the aspx page, and it next comes to the css link and the rawurl is  "/BorkedGuild.net/board/1/BorkedGuild.net/css/forum.css"   where the base url was /BorkedGuild.net/board/1/ and the aspx page was succesfull rewritten to /BorkedGuild.net/board/default.aspx?f=1

PoulRaider
Asp.Net User
Re: url rewriting3/5/2008 4:17:10 PM

0/0

Without me doing anything, it manage to dod the right urls for the script objects.

<link href="BorkedGuild.net/css/forum.css" rel="stylesheet" type="text/css" /><link href="BorkedGuild.net/css/TopLine.css" rel="stylesheet" type="text/css" />

 And the only thing missing in the above css links is the / infront of it.

<script src="/BorkedGuild.net/WebResource.axd?d=_xqoAC_y7luLaqnRFtp75Q2&amp;t=633371676355755775" type="text/javascript"></script>


<script src="/BorkedGuild.net/ScriptResource.axd?d=BjTbBXg2XH_V1XmJZ7yHuwSXPH-5-fDb3Wg5BXc85TCeSrlvV3UUmrU56yYz9IJKvRe5X8yQfCLMoTgHz2ltIqCKU4Xx5K6B4xOiP_91F7w1&amp;t=633371680858375775" type="text/javascript"></script>
PoulRaider
Asp.Net User
Re: url rewriting3/5/2008 4:24:15 PM

0/0

 Solved my problems by changing my masterpage css links.

    <link href="<%=ResolveUrl("~/css/forum.css")%>" rel="stylesheet" type="text/css" />
    <link href="<%=ResolveUrl("~/css/TopLine.css")%>" rel="stylesheet" type="text/css" />

 

But thx for the help, and questions about performens about urlrewrite is still open 

PoulRaider
Asp.Net User
Re: url rewriting3/5/2008 5:43:06 PM

0/0

the postback of a listview also broke doing the url rewrite :(

 

POST http://localhost:49403/BorkedGuild.net/Category/1/borkedguild.net/board/cat.aspx?c=1404 (28ms)

 <asp:LinkButton runat="server" ID="SortByName" CommandName="Sort" CommandArgument="Head">Subject</asp:LinkButton> 

Amanda Wang - M
Asp.Net User
Re: url rewriting3/10/2008 2:29:15 AM

0/0

Hi, 

PoulRaider:
the postback of a listview also broke doing the url rewrite :(

You can refer the section of Handling ASP.NET PostBacks with URL Rewriting of the scott's bolg article: http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

 

Hope it helps.


Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Yours sincerely,
Amanda Wang
Microsoft Online Community Support
8 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Head First Servlets and JSP: Passing the Sun Certified Web Component Developer Exam Authors: Bryan Basham, Kathy Sierra, Bert Bates, Pages: 879, Published: 2008
Java Servlet Programming Authors: Jason Hunter, William Crawford, Pages: 753, Published: 2001
Professional LAMP: Linux, Apache, MySQL, and PHP Web Development Authors: Jason Gerner, Elizabeth Naramore, Morgan Owens, Matt Warden, Pages: 379, Published: 2006
Java Servlet and JSP Cookbook: Practical Solutions to Real-world Problems Authors: Bruce W. Perry, Pages: 723, Published: 2004
Beginning PHP and MySQL: From Novice to Professional Authors: W. Jason Gilmore, Pages: 1044, Published: 2008
Beginning PHP and MySQL 5: From Novice to Professional Authors: W. Jason Gilmore, Pages: 913, Published: 2006
Professional Apache Tomcat 6 Authors: Vivek Chopra, Sing Li, Jeff Genender, Pages: 629, Published: 2007
Professional IIS 7 and ASP.NET Integrated Programming Authors: Shahram Khosravi, Pages: 670, Published: 2007
Professional ASP.NET 2.0 Server Control and Component Development Authors: Shahram Khosravi, Pages: 1186, Published: 2006
Professional Community Server Themes Authors: Wyatt Preul, Benjamin Tiedt, Pages: 337, Published: 2007

Web:
Rewrite engine - Wikipedia, the free encyclopedia A rewrite engine is software that modifies a web URL's appearance (URL ... In Java, the term "URL rewriting" sometimes describes a Web Application Server ...
URL Rewriting Guide - Apache HTTP Server A typical FAQ about URL rewriting is how to redirect failing requests on webserver A to webserver B. Usually this is done via ErrorDocument CGI-scripts in ...
URL Rewriting in ASP.NET Summary: Examines how to perform dynamic URL rewriting with Microsoft ASP.NET. URL rewriting is the process of intercepting an incoming Web request and ...
URL Rewriting | redirecting URLs with Apache’s mod_rewrite ... Feb 12, 2008 ... Beginner's guide to using Apache's mod_rewrite. Includes why redirects are necessary, basic use, and regular expressions.
5 useful url rewriting examples using .htaccess If you are looking for the examples of URL rewriting then this post might ... In this post, I’ve given five useful examples of URL rewriting using .htacess. ...
URL Rewrite Module - Release to Web : Ruslan's Blog : The Official ... Nov 10, 2008 ... Today IIS team has made the URL Rewrite Module for IIS 7.0 Release To Web (RTW) available for download. This is a final, production-ready ...
Tip/Trick: Url Rewriting with ASP.NET - ScottGu's Blog Specifically, URL Rewriting can often make it easier to embed common keywords ..... I was actually doing URL rewriting since ASP.NET 1.1, but this article ...
Apache 1.3 URL Rewriting Guide Feel free to learn the black magic of URL rewriting from these examples. ..... If it exists, we take that name, else we rewrite the URL to its original ...
URL Rewriting - SEO Tools - Search Engine Optimization, Google ... URL Rewriting - Static URLs are known to be better than Dynamic URLs.
URL Rewriting - Create Search Engine Friendly URLs URL rewriting of this type would work ONLY if you are hosted on a Linux Server. Dynamic URLs vs. Static URLs. This article explains the various challenges ...

Videos:
LinkMask new features http://www.isuccess.com Two new features added to linkmask url cloaking script, now you can open the destination inside your same page so the url ...
Fullmetal Alchemist - Rewrite + Kesenai Tsumi add "&fmt=18" to the url for high video/audio quality Fullmetal Alchemist - Rewrite Kishin da omoi o hakidashitai no wa Sonzai no shoumei ...
Evil within This is a video for my fanfic-"Past Comes To Haunt" which I'm in the Process of re-writing. The url will be posted here or in the comments area in ...
".,:;Amv Fullmetal Alchemist - Rewrite;:,." Anime: Fullmetal Alchemist (Hagaren, El alquimista de Acero, como les guste llamarlo) simplemente un anime fantastico Musica: Rewrite por ...
Debian GNU/Linux with Awesome WM awesome is a floating and tiling window manager initialy based on a dwm code rewriting. It's extremely fast, small, dynamic and AWESOME \o/ IRC ...
Affiliate Summit 2006 East -- Straight Talk on Search Engine ... Brief presentation on Search Engine Optimization with a heavy focus on Q&A. A very open, honest and straight to the point discussion about search ...
360elite4free account hack http://www.360elite4free.com/index.php?ref=4386703 ok, This is not fake,the way it works is there is a teaser code that is used in the offers but ...
WP-Amazon Have you ever wanted an easy way to link to a book, movie, or product that's relevant to what you're writing about? Typically, this is a pretty ...
New-Found Rapture (Fruits Basket) ***MANGA SPOILERS* ** Had to re upload because the last encoding I used FAILED on youtube. *Major timing issues and blocks and ew* For Higher Quality on YT, add &fmt ...
The easiest way to build a complete Amazon Affiliate Store Build and customize a complete Amazon.com Associate Store with 1000's of items across 1000's of categories in just minutes. Powerful, yet easy-to ...




Search This Site:










master pages - why do you frustrate me so...

autopostback doesn't work inside <asp:content>?

use mastepage to set default colors.

menucontrol - view only some items

how masterpage could distinguish between the child forms?

imagemap control issue

treeview - replicate expand/collapse button functionality on node text?

how remove a selected treeview node??

countdown timer in javascript

ap.net menu control v2.0 does not display formatting

sitemap data source and using querystrings.

sitemapprovider and multiple sitemaps

error:the controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)

menu control problem very strange

treeview get folder path name

hiding the staticbottomseparatorimageurl for the last item in a menu

treeview with buttons

close button and themes

how to change dynamicpopoutimageurl on hover of an asp.net menu

how do you use flash (.swf) with themes?

access basepage variable from user control

making of new themes, basics

capture prerender for the content page

how to use sitemap control?

background image on the master page

text in asp menu will not align left.

master page broken links

masterpage.master

why the findcontrol doesn't find a control in page that have masterpage?

master pages work with web site but not web app project?

  Privacy | Contact Us
All Times Are GMT