I'm using webforms with UrlRewriting.Net to rewrite pages, e.g.
http://www.example.com/stuff.aspx?c=30
becomes
http://www.example.com/stuff/30-this-stuff.aspx.
It works in so far as the correct content is loading; however, none of the postbacks are working (mostly buttons on the page). If I set up a breakpoint on Page_Load, I see that IsPostBack is always false. Any ideas on how to fix this? Right now I'm just on Visual Studio 2008.
EDIT:
I have since switched to UrlRewriter.Net, which worked after a few tweaks (see Scott Gu's article). Besides here, I have posted my original problem to the developer's forum: if I ever get an answer, I'll post it here (unless else posts it here first).
You need to make sure it is doing something called ClientRebaseing which makes sure .NET is seeing the new URL vs the old Raw URL. See this post for more information:
http://www.ifinity.com.au/Blog/Technical_Blog/EntryId/46/Why-does-Url-Rewriting-break-all-my-image-links
Also I don't know if this is supported in UrlRewriting.NET, but my own URL Rewriter based off of Apache mod_rewrite does support rebasing the client path.
http://urlrewriter.codeplex.com
I could be way off here, but I worked on a project that used UrlRewriter.Net and from what I remember, I think the issue you're having is not rewriting the form element's action attribute. View your source and see if the URL in <form action"..." ... /> is the same as what's in your address bar. I don't know how we did this because it was at another job and the technical lead there wrote the code to do that, but I imagine you would change the rendering of the form tag.
Related
I have inherited a project written in .net webforms, basically just an old site that needed to be skinned/made responsive. All of that is done and functions as it should. However I noticed that the old version of the site didn't contain a 404 page, something that I feel is necessary for this site. I've made a 404 page but what I want to do is display the URL on the page. So it'd be something like
<div>
<h1>Something went wrong with</h1>
<h2>Page URL here</h2>
</div>
I know in MVC.net you can write http://www.domainname.com#(Request.QueryString["aspxerrorpath"]
but whats the equivalent in webforms?
FYI the "backend" of each page is written in VB
Thanks in advance
I originally misread your question and advised Server Variables for "URL", then realised you're on a custom error page, so it would just show the URL you're on.
Perhaps you can use the Referring page?
<%=Request.ServerVariables["HTTP_REFERER"]%>
Additional info
ASP.NET aspxerrorpath in URL
HI so i keep running across websites which when looked through or searched (using their own search function) return's a static URL ie.) ?id=16 or default.aspx no mater what page of the website you visit after the search has been performed. This becomes a problem when i want to go directly to a post/page within one of these sites so i'm wondering. If anyone knows How could i actually find out what the absolute URL is.
So that i can navigate straight to it. I'm not really familiar with coding but have tried looking in the page source but i wasn't really able to gleam anything from there.
The basics around asp.net urls: http://www.codeproject.com/Articles/142013/There-is-something-about-Paths-for-Asp-net-beginne
It all really depends on what you're trying to find, as far as finding a backway to locate a absolute path, is highly doubtful. If the owner of the site(most blogs) want you to have a perma link to a page, they use url-rewriting for putting things in the URI like title page and such. Alot of MVC sites do this now.
The '?id=16' you're seeing is just a query string, a holder for other logic they are doing.
I'm bulding an ASP.NET website just to test my skills, and I'm using lots of callbacks that doesn't require a page refresh, and the URL doesn't change. In this example, assume I'm bulding a web-based Outlook with a treeview, a grid, and a detail pane.
Is there a standard (published or assumed) that says I should postback, or even update my URL from time to time?
The Standard you are probably looking for is called usability. DHTML, Ajax, or whatever you want to call it is fine until it breaks the users expectation of browser behavior. When the back button fails to work, and users can't bookmark the page exactly as they expect, you're doing it wrong.
I don't know about an official standard, but you may want to check out Gmail to see a good example of how something similar was done. The URL changes on the site much more often than the page refreshes.
I have an asp.net C# .net 3.5 page which contains several user controls. I am noticing that sometimes the html loaded on the browser is incomplete. It seems to get cut-off.
Any suggestions on how to troubleshoot whats the root cause?
This can be symptomatic of server errors or proxy problems. I would use Fiddler to check what's going back and forth between your browser and the server. If you are getting any 500 (server error) response codes, that would be a good place to look.
Another thing to check would be javascript errors on the page, because depending on what your javascripts are doing, errors can prevent loading of other content in some cases.
womp probably has most of the bases covered, but the other angle that can lead to issues like this would be exceptions getting eaten but causing processing to stop, thereby sending half the page or somesuch.
Verify that your HTML is being written to the page by viewing the source code of the page after it loads. My guess is that the HTML that is being output is invalid, and that the browser isn't able to properly display it. Make sure all your HTML tags are properly closed and balanced.
It could also be an issue with the request being ended midway through. Try removing one control at a time from the page and see if the situation improves. If it does, you'll know which control is to blame.
It is quite unlikely that it is the same problem, but I had that happen before where the page had a custom filter attached to response.filter which reformatted the output to fix up some dotnet SEO problems. And the one we wrote had a bug where one regular expression consumed a bit too much copy in some instances and broke the output
This is actually a follow up on my previous question (link)
I've created the HttpHandler and it works fine for now, I'll add flexibility by using the querystring and session to point the post I'm making in the right direction.
The next question is as follows.
Now that I have the old page iframed as it should be, there's still the trouble of handling the postbacks (or actions) these pages trigger.
Every button action (asp form post) refers to a page that is not there (it's on the other server from which I am importing functionality).
I've tried using a url mapping to the other server but I get an error that tells me the external link is not a valid virtual directory. Hence I discarded this option.
I there anyway to keep functionality going inside the iframe?
please do ask clarification if you need it.
I got a solution from a colleague.
before passing the response string to the Iframe from the handler I use a string.replace to adjust the urls in the old site. This way they point to the old site and everything works again :)