Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How to load index page with QueryString in asp.net? I know that we can redirect to a particular page with QueryString, but what I want is to load first page with some querystring.
If you are setting start action in Property pages of your application then you can follow following steps
1) right click on your project in solution explores
2) Go to Property pages
3) Set start action to 'Specific Page' and value = "index.aspx?a=22"
A very simple way to make it work on both local and remote enviroments is to, at page_load(), detect if the desired QueryString content is present.
If not, Use Response.Redirect pointing to the current page with the added QueryString parameters. Example follows:
if (Request.QueryString["QSEntry"] == null)
Response.Redirect("Page.aspx?QSEntry=desiredValue");
Pro: It'll work the way you want.
Con: You're actually loading the page twice (first time it's a parameterless load), so don't forget to take that into consideration.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm having problems parsing information from a forum.
Heres some examples:
Easy
Hard
It would be really easy to get the information as they are displayed in the div where id = "poe-popup-container".
The problem is that that div is only populated when the browser allows you to see the information. That can be easily reproduced by making your browser height really small and looking in the HTML code for the . However, the div will be empty, but as soon you scroll down to see the item it will change.
I'm trying to read the nodes inside the with htmlagillitypack. The problem is that, as i explained, it only has information when the browser says that you need that information.
So, when you try to download the html, the div is empty.
I've tried to download the page with the web browser too, but the same thing happens.
I'm trying to use the following code:
string page = System.Text.Encoding.UTF8.GetString(Webclient.DownloadData("http://www.pathofexile.com/forum/view-thread/966384"));
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(page);
HtmlNode node = doc.DocumentNode.SelectSingleNode("//div[#id='poe-popup-container']");
MessageBox.Show(node.InnerHtml);
You're trying to do impossible. Javascript is executed in browser. HtmlAgilityPack is library just for parsing static html - it can't execute javascript.
So why don't you look into browser automation instead ? Try for example http://watin.org/
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have something I'd like to attempt, but am unsure of the best path to accomplish it. I have a page, say default.aspx, that creates some content. I also have a second page, say input.aspx, that creates a small select box. This box is to be loaded via ajax on a chang emade on default.aspx. However, I also need this box to initial load in the codebehind of default.aspx.
Example:
1. default.aspx codebehind creates content and loads input.aspx in the codebehind
2. field changes on default.aspx and input.aspx is changed via ajax using Jquery
However, I cannot seem to find the best possible way to load a second ASP.NET page into the codebehind of the initial page. I was considering using an HttpWebRequest object, but am not sure the syntax. Any help would be appreciated.
Thanks!
At Request of #Mbeckish
What I need to happen is outlined below step-by-step
default.aspx loads with content generated from codebehind
Also in codebehind, a select box is loaded (I have this in a separate input.aspx file now. This is the step I need help with.)
default.aspx response is returned and displayed on client
user changes a form value on default.aspx
the select provided by input.aspx is reloaded from server (I currently use a JQuery ajax request to allow this)
Sounds like your second page 'input.aspx' should really be a UserControl (.ascx file), which you dynamically load (using Page.LoadControl(...)) in your default.aspx page.
What you need is to add an iframe to default1.aspx and set it's src property to be the other page
<iframe src="otherPage.aspx"></iframe>
http://www.w3schools.com/tags/tag_iframe.asp
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have some logic in Session_Start and this logic is actual for all my controller methods except one special method. I need to not execute Session_start logic, when user goes to special method URL.
Any ideas how I can do that?
As far as I understand your question, you do not want the code within your Session_Start method to be invoked if a special url is requested. I think it would be helpful to know what your problem is, that you want to solve. For now here is my answer:
Since Session_Start is only invoked once (at least usually, depending on your configuration of the session module - see my comments to your question), this only works if the client invokes the "special" url first, e.g. before calling other urls. If another url has been invoked first, session will be initialized according to your code. Important: as mentioned, depending on your configuration, there will be always a Session (but in this special case you do not want to execute your custom logic in Session_Start):
You can use the Current HttpRequest and perform a check on some properties:
// this will (usually) only be called once, on the first request of the client
protected void Session_Start() {
// perform your check here if this is the url you want to exclude
if (HttpContext.Current.Request.Url.OriginalString.ToLowerInvariant().EndsWith("something")) {
return;
}
// your initialization here that should not be executed for clients accessing the site using the above url
}
As you can see, you can access the Request object, and perform your check there, depending on your requriements.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
what is the meaning of skip the login protect in asp.net,
and the difference between server.Transfer() and Response.Redirect()?
My mind:
the meaning like that i can write some queryString on the URL direct and this request can be solve.isn't it?
the difference between server.Transfer() and Response.Redirect() is that response.Redirect() redirecta to another page and the URL will be changed, however Server.Transfer() cannot change the URL.
Is this right?
Per MSDN:
HttpServerUtility.Transfer Method (String) - For the current request, terminates execution of the current page and starts execution of a new page by using the specified URL path of the page.
HttpResponse.Redirect Method (String, Boolean) - Redirects a client to a new URL. Specifies the new URL and whether execution of the current page should terminate.
To Elaborate
Response.Redirect sends a 302 HTTP status code to the browser, which tells the browser to go to the new URL.
Server.Transfer will shunt the processed request of another .aspx page to the current request, leaving the URL unchanged, an operation that happens entirely on the server.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i am using C# and sql database. In db is stored information about items - id, name, etc.
Now i have a page to show items, that i use as a template and pass Item id in the url like /Item.aspx?id=223.
I would like to create pages for every item and save them to folder like /Items/Red-Book.aspx.
Any suggestions?
Thanks, Walt
You don't need to save the pages physically. You only need one page Item.aspx which will generate the content according to the ItemiId you supply. (the same way you explained in the question)
After you have this page you need to look into how to rewrite URL.
What rewrite URL does is that it takes the url that a user requested and rewrites it to something else.
If a user request /Items/Red-Book.aspx the url will be rewrited to /Item.aspx?id=223 and youre ASP.NET will load /Item.aspx?id=223 back to the client.
You can make use of the method RewritePath which you can call at Application_BeginRequest to rewrite your URL.The logic would be as follow:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
var currentPath = HttpContext.Current.Request.Path;
// do some logic to generate newPath
var newPath = GetNewPath ( currentPath );
HttpContext.Current.RewritePath(newpath);
// after this point ASP.NET will work as the user would have requested newpath
}