Is it possible to modify Request.ReferrerUrl using a URL argument? - c#

I'm trying to get around an issue for a customer that have a site developed by a previous developer. The following is the line of code causing the issue:
args.AddParam("REFERER","",Request.UrlReferrer.ToString());
Therefore if you navigate directly to this page using the URL, it returns a null exception error. I know that to fix this the code should first be checking if UrlReferrer is set to null, however I am trying to find a way around this problem without having to change any source. Any help would be appreciated

No, there is no URL (Querystring) argument that can set the REFERER http header to something. The only way you can do it is to link to the page from another one, and only navigate to it in that way.

Related

Yammer Oauth/application confusion

I need to just search Yammer for a various string on the timeline and facing a few weird issues.
Using Nuget, I got the yammer.simpleapi package (Found the bug everyone was talking about and changed it from GET to POST) and I created an App on Yammer, but, this is where the fun starts.
I have a local page http://localhost/home/yammer which redirects to Oauth and then redirects to my app with the key and I retrieve basic user settings.
Now, this is where I get confused - I see if I refresh this page, I just get a blank response (I guess that the code is only good for one query?), but if I refresh the http://localhost/home/yammer - I sometimes get the correct response and sometimes I get nothing.
This is best shown in a recording I did - https://youtu.be/RqrAGiP7Rh4
This is really annoying me and I was wondering if anyone knows what is going on?
I would post code examples, but, there hasn't really been anything modified from the original yammer.simpleapi other than the keys.
The web example app is just working one time.
If you want to replay your page, you should save your YammerClient somewhere (or declare it in static)

Is there a way to detect 404 pages using HtmlAgilityPack?

I am parsing a forum where some threads are already deleted. So opening them still shows a page but with a message that says "Thread no longer exists". Is there a way to query this using the HtmlAgilityPack in a special way?
Or do I have to compare the InnerHtml or something along those lines?
a 404 is not actually being returned. If it was, you could just look at the headers.
That said, you are getting a 200 response with an error in the html, therefore you will have to parse the html, traverse the DOM, whatever you want to call it and determine if it failed.
It appears that there could potentially be several different error messages, so I would try to make your comparison generic by looking for the "notify administrator" link or perhaps the class="blockrow restore" is only used on the error page.
Hope that helps.

ASP.NET Masterpage and Context.RewritePath

In my ASP.NET Website, I am trying to use Server.Transfer to redirect client to different url(all pages resides in same domain) instead of using Response.Redirect because of performance issue and heavy flickering. But when I use Server.Transfer, all session values are wiped out and getting NullReference error even though if I enable page level EnableSessionState. After several attempt, i tried Context.ReWritepath just to change the url and lost all masterpage contents like menus, headers. Any idea? Any help? Am i doing anything wrong?
This technique is great for wizard-style input forms split over multiple pages. But there's another thing you'll want to watch out for when using the preserveForm parameter. ASP.NET has a bug whereby, in certain situations, an error will occur when attempting to transfer the form and query string values. You'll find this documented at
Q316920
The unofficial solution is to set the enableViewStateMac property to True on the page you'll be transferring to, then set it back to False. This records that you want a definitive False value for this property and resolves the bug.
Read More here

append query string to URL on event (C#)

my client has a website that currently makes requests on a particular event (click, load etc). the website is working well and all but he has a problem with getting the website statistics with Google Analytics, the reason is, because the website never does a re-direct to a different page, it is all within the same page and no matter what event is loaded in the website(be it a video, tables etc) everything are displayed under the same url
www.somewebsite.com/default.aspx
what I want to achieve is on a particular event, change the url to
www.somewebsite.com/default.aspx?type=abc&id=999
How can I do this,. what is the easiest method to do this? please advise. The whole website is built in C#.
Many Thanks.
Is this event happening on the server or the client?
If it's on the server, you can call Response.Redirect and add your new query string parameter to the current url.
If it's on the client (Javascript), you can set the location property.
If you want to preserve your page's state, try adding your querystring parameter to the form's action parameter in Javascript.
Alternatively, as jeffamaphone suggested, you can change the hash (the part after the # sign) by setting location.hash without posting back to the server.
Actually, you should probably move some of the elements to different pages... this is based on what you said:
because basically all I am doing is
hiding and showing elements based on
events, if i do a response.redirect,
it will reload teh homepage.
If I understand correctly, the user is never redirected to a different page, you are just hiding/unhiding elements from default.aspx based in query strings... correct? the simplest solution will be to split that content into different aspx pages.

object instance not set on page load?

I am trying to load my website and it says object instance not found. What do i do??
make sure that the object that it is complaining about is instantiated before it is used...or check it for null before using it. Can you post the actual error and code here so we can see more detail?
More info please.
You flagged C# so can I assume ASP.NET? What version?
What version of IIS?
Did it ever work? Have you changed anything?
Can you strip stuff out to get soemthing working? Then add back a step at a time?

Categories