.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

postbacks and url rewriting

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

Hi all,

I am using Intelligencia url rewriter for my project and have run in a small problem. I have a regular expression like

<rewrite url="~/(.+)/(.+)/(.+).aspx" to="~/Article.aspx?a=$3&amp;s=$2&amp;p=$1"/>

so a page request like

/parent/category/articlename.aspx is interpreted as /Article.aspx?a=articlename&s=category&p=parent.

This above is all fine, but now when I do a postback (a login block), it picks up the url /Article.aspx?a=articlename&s=category&p=parent and interprets as /Article.aspx?a=article&s=category&p=parent.

Now, how can I make sure that on the postback, it still throws back the original url /parent/category/articlename.aspx so that the url is properly interpreted?


View Complete Post

More Related Resource Links

URL Rewriting

If you click on the link you can have look at how the URL rewriting is working. It can be easily understand with screen shot!!!


URL rewriting with webserver in VS.NET2010



is it possible to have same URL rewriting behaviour in integrated webserver as in "real" IIS7?


css and images gone on url rewriting


 I have a program which rewrites a url to a form     website.com/Default.aspx/name/articleid

The Program works fine ,but after URL rewriting my css sheet and images are gone . 

I am new to this and I have read that I should map my css and images to root. 

So ,I hav done some change to the path files of css and images but it stilll doesnt work .

Plz help me over this ...... 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TBV.aspx.cs" Inherits="TBV" %>

<!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 runat="server">
    <title>Article Page</title>
    <link rel="index" href="~/" title="Home" />
    <link rel="Stylesheet" media="screen,projection" type="text/css" href="~/css/main.css" />
    <link rel="stylesheet" media="print" type="text/css" href="~/css/print.css" />
    <link rel="stylesheet"

Security Briefs: Protect Your Site With URL Rewriting


Learn the numerous ways in which you can rewrite URLs to defend against common Web vulnerabilities.

Bryan Sullivan

MSDN Magazine March 2009

Keep "collapsed" state of CollapsiblePanelExtender between postbacks



I have created a UserControl with a CollapsiblePanelExtender inside. In my Web page, I have a PlaceHolder in which many UserControls are added dynamically at every PostBack.

Everytime my page reloads, the CollapsiblePanelExtenders are expanded, even if they were collapsed before the PostBack. Is there a way to keep track of the "collapsed" state of the CollapsiblePanelExtender ? It seems hard since there is no server event triggered when the panel is collapsed / expanded.

Someone seemed to have the same problem here : http://forums.asp.net/p/1094970/1650425.aspx. I tried his solution (accessing the ClientState of the CollapsiblePanelExtenders using Request.Form) but my values are always null or true, even if the CollapsiblePanel is collapsed before PostBack.

Here is some piece of code :

AUMBlock block = (AUMBlock)Page.LoadControl("AUMBlock.ascx");
//CollapsiblePanelExtender cpe = (CollapsiblePanelExtender)block.FindControl("cpe");
//string clientState = cpe.ClientState;

URL Rewriting Dynamic

Hi, i am  having problem with the below urls to rewrite. http://www.mywebsite.com/products.php?shprod=345http://www.mywebsite.com/products.php?cat=cars  i want them to be displayed http://www.mywebsite.com/products/345http://www.mywebsite.com/products/cars i want to take query string based on the requested. but it is taking  the secong one, How to differenciate the Query string whether it is "shprod" or "cat" Please give me solution

URL Rewriting subdomains

Hi. I'm trying to create a mini-blog for some users which would use http://name.mydomain.ext form for access. Is it possible to use URL rewriting to transfer http://name.mydomain.ext to http://mydomain.ext/userarea.aspx?user=name. Thanks.

How to access querystring values from javascript after url rewriting?

Hi mates, I´m using ASP.NET 3.5 with C#. The problem that I have is the following. I´m using url rewriting (in the Global.asax file) and people see urls like this:http://localhost:1855/uk/london but after I rewrite the urls I work internally with querystring values and the urls become somehting like this:http://localhost:1855/post.aspx?co=1&ci=1In my Global.asax after I create the proper url with the querystring values I just apply it with the following sentence (this is an example):Context.RewritePath("/post.aspx?co=1&ci=1");The problem is that from javascript using the following function I access the first url and not the second:function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } } I need to access the querystring values because I need to load values in a textbox using jQuery.autocomplete and Web Services. Can anyone tell me how to access the rewritten url to get the querystring values?Thanks in advance mates

Problems with url rewriting when using the ASP.NET development server

I've inherited a website which has been developed for IIS server. The hyperlinks in this website have a href attribute with the human readable form that appears in the url in the browser's searchbar. In Application_BeginRequest(), there is a method which will convert this into the acutal location of the page within the website's file structure.This works fine when running the website on IIS. However, when I am using the ASP.NET development server, the links do not work and I get a page not found error.I have noticed that Application_BeginRequest() is never called for the links when run using the ASP.NET development server. I have read that the ASP.NET development server will not serve pages that are outside of the application scope (http://msdn.microsoft.com/en-us/library/58wxa9w5%28VS.80%29.aspx), as the human-readable urls would appear to be when first processed by the server.Bear in mind that the urls in the aspx files are in human readable form, so I can't just use ResolveUrl(), because they don't correspond to files in the internal file structure until they have been re-written.I want to get the website running on the ASP.NET development server so that I can test it locally on my machine, which I can't really do if I can't get the url re-writing to work. Is there a way around this problem?

General Question About Remembering Property Values Between Postbacks

Here are examples of two different ways I've found to story Property values between postbacks:    private bool Initialized    {      get      {        return Convert.ToBoolean(this.Attributes["Initialized"]);      }      set      {        this.Attributes["Initialized"] = value.ToString();      }    }    private int DataTableRowIndex    {      get      {        return (int)ViewState["DataTableRowIndex"];      }      set      {        ViewState["DataTableRowIndex"] = value;      }    }I'd appreciate any comments about differences between these two approaches [Attributes vs. ViewState].  Is one better or worse?Robert

How to Pass a Grid an EF Object and have it edit/update etc. without postbacks until save?

Hey all.Here's what I'm trying to do:I want to pull an EF object, or create a new one. Pass it to javascript (jquery or some such) and then have the grid bind on the client side and do everything client side from that point forward. (edits, validation etc.) Once complete, I want jquery to push back via a pagemethod or web service or whatever, the updated EF object so that i can persist it.Reason?I need a highly scalable architecture that handles not storing objects in the session or posting to a database when they haven't been saved to a user. I know I can do this with Silverlight, however given MS's less than convincing comments about Silverlight's future vs HTML 5, I'm strongly leaning towards asp.net or mvc.net if I can come up with a way to use jquery (or even a 3rd party control that does this!) to handle all of the data editing, updating etc. for a master/child display (i.e. Invoice) without the server having to store it and without having to use the viewstate.Ideas?In my mind this would be the holly grail. Render the page, push the data to the controls, have the controls do their thing until save without ever doing server processing, and then on save, push back the object and allow the server to persist it (and probably do server validation before presisting it just in case). By doing this you could make superscalable apps that

UpdatePanel in .Net 4 - Causing Full Page Postbacks

Hi Guys,I've just updated a website from 3.5 to 4.0 and I've noticed that paging controls and command buttons in update panels cause full page postbacks (where they never use to in my 3.5 version).Any ideas why this might be?Cheers,Andrew

asp:Menu causes sys undefined with URL rewriting

Hi, I'm developing using the new ASP.NET 4 and I ran into the following issue. When I put a Menu control into the web form, the menu causes the following code to generate just before the closing </form> tag:<script type='text/javascript'>new Sys.WebForms.Menu({ element: 'NavigationMenu', disappearAfter: 500, orientation: 'horizontal', tabIndex: 0, disabled: false });  As long as I don't use URL Routing, the page compiles and loads properly. But when I try to use URL Routing on the website, VS starts to throw "Sys is undefined" exception. However, this does not happen always. Most frequently it happens when I change somenting positioning-related in the CSS file, but sometimes the exceptions seems just arbitrary. I'm not sure which parts of code could help, if any. I would appreciate any help. Thx

Play uninterrupted music across postbacks

Hi,I'm in need of providing uninterrupted music to the visitor of my web site.The music is played by a 3rd party Flash object. I need to some how maintain an instance of this flash object in memory so that the visitor of the site will experience uninterrupted music (even while navigating to the other pages in the site).The idea is to have one instance in memory (hidden which survives postbacks) and the othe displayed to the visitor (this will sync up with the hidden player).If you suggest using iFrame in a master page, pl let me know how to handle multiple master pages scenario. My site contains more than one master page. And with iFrame we don't get to see the actual URL being served in the address bar.I know pop-up window is another option. But would like to know if I can do anything with the iFrame.Thanks.

URL Rewriting

Hi,   Hoping someone can help point me in the right direction here. I am building a custom application, it allows users to sign up and create an account and add details. What I would like to achieve is that when the page is visited: www.blahblah.com?userID=2 The resulting URL to the user is www.blahblah.com/RichardJones.aspx or www.blahblah.com/RichardJones I've had a look at url re-writing posts button cannot find anything specific to this scenario. Does anyone know of any good information sources where I could find out how to do this? Thanks in advance

Partial view and postbacks - undesired results

Sorry for the long post,I'm having problems after the postback. Each time I post back the changes made on the ui - I see the changes in the RateViewModel passed back, but the code populates each control in the table with these values - instead of the values from the ViewModel. What am I doing wrong?Object.public class CurrentAndFutureRate{        public int ParentID { get; set; }        public int ParentTypeID { get; set; }        public string ParentTypeDescription { get; set; }        public decimal CurrentRateValue { get; set; }        public DateTime CurrentStartDate { get; set; }        public DateTime? CurrentEndDate { get; set; }}View Modelspublic class CurrentAndFutureRateViewModel { public List<CurrentAndFutureRate> CurrentAndFutureRates { get; set; } } public class RateViewModel { public int ParentID { get; set; } public int ParentTypeID { get; set; } public int? RateID { get; set; } public decimal RateValue { get; set; } public DateTime StartDate { get; set; } public DateTime? EndDate { get; set; } } Master page renders a partial view(1) and the partial view displays a table

unecessary postbacks

Hi I am trying to delete or add rows in a table but since the table is in an update panel, upon deletion the row goes away and then comes back. I have tried using return false but it does not seem to work in IE or FF. I am using the following code:$(document).ready(function () {$(.table).click (function ()}(this).parent().remove();});return false;});Basically I need a way to disable the postback.Thanks
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend