Query String - How To Intercept And Pre-process QueryStrings

Mar 24, 2010

We send out registration urls to clients via email. Some of the email clients are turning the url intourl <url>I think it may be happening when users forward the email onto themselves at which point the email client re-formats the original email (maybe)[URL]Which rightly producesSystem.Web.HttpRequestValidationException: A potentially dangerous Request.QueryString value was detectedWhere in the code should I intercept these instances and santize the url so that the user is re-directed onto the original form of the url?

View 1 Replies


Similar Messages:

Web Forms :: Intercept Server Side RaiseCallbackEvent (string EventArgs) ?

Mar 4, 2011

I have a server side control RaiseCallbackEvent implemented. I want to intercept raisecallbackevent after it finished executing RaiseCallbackEvent method in the serverside and want to execute other code in the .aspx template.

1) Is there any pagelife cycle event that fires after RaiseCallbackEvent?

2) Is there any way to fire jquery function after RaiseCallbackEvent from client side?

View 1 Replies

C# - How To Process The Values Of Optional Query Strings

Nov 3, 2010

I'm pretty new to C# and ASP.NET, so bear with me on this one. I'm setting up a page that receives query strings from the url. It then passes these strings to another method (in another class, actually), which goes on to do lots of things depending on the value of the query string.

The general structure looks something like this, where DoSomething() is actually part of another class that will be used by lots of different pages:

pretected void Page_Load (object sender, EventArgs e)
{
DoSomething (Request.QueryString["name"]);
}
public void DoSomething (string UrlVariable)
{
// if UrlVariable isn't set, initialize it to some value
// do stuff with UrlVariable
}

Here's what I'm wondering:

If the query string "name" isn't defined in the url, what does Request.QueryString return? an empty string? null? If it returns null, what happens if I try to pass null to a method that is expecting a string? Does the whole program fall apart, or can I check for null inside the DoSomething() method (after receiving the null string)?

The "name" is optional, so if the user doesn't set it, I'd like to detect that and initialize it to some default value. If possible, though, I'd like to put any validation inside DoSomething(), instead of doing the check on every page that requests the string.

View 2 Replies

Query String Can A Query String Contain An Url That Also Has Query Strings

Nov 22, 2010

Example:

[URL]

I added the iis tag because I am guessing it also depends on what server technology you use?

View 3 Replies

State Management :: How To Pass Dynamic String Through Query String With Java Script

Dec 24, 2010

I m facing some problem. i m not passing Dynamic string through query string..

I m using this code

string abc = "CPCB_" + TextBox1.Text + "_" + TextBox2.Text;

Response.Write("<script>window.open('xml.aspx?Flag=3&date='+abc,target='new');</script>");

View 2 Replies

Web Forms :: How To Send A String Consists Of (,.&') In A Query String

Dec 7, 2010

Is It Possible to send a string consists of (,.&') in a query string ?

View 7 Replies

C# - Cannot Pass A Input From Text Box To A Query String And Then Keep The String In This Box?

May 28, 2010

I have a simple ASP.net page:

<form id="form1" runat="server">
<p><asp:TextBox id="input_box" runat="server"></asp:TextBox>
<asp:Button Text="OK" runat="server" OnClick="run" /></p>
</form>

I want to send input from input_box to a query string, and then keep this input in the input_box when the page reloads.

That's the code behind page:

protected void Page_Load(object sender, EventArgs e)
{
input_box.Text = Request.QueryString["input"];
}
protected void run(object sender, EventArgs e)
{
string url = string.Format("?input={0}", input_box.Text);
Response.Redirect(Request.Url.AbsolutePath + url);
}

Problem is that when query string is not empty, string from input_box cannot be passed to query string. How to correct it?

View 1 Replies

Sending An HTML Encoded String In The Query String?

Jan 5, 2011

We are sending an HTML encoded string in the Query string. It was working fine on IIS 6 (windows 2003). We have recently moved the website to Windows 2008 (IIS 7.x). Since the move any Query String that contains "+" sign i.e., "%2b" gives error on the server "404 -File or directory not found."

View 2 Replies

Assigning String Text To Variable - Process And Display

Jan 6, 2010

I need to accomplish a simple task like this:

1. Assigning text of a few lables to corresponding variables.
2. Taking/posting these variables to server and process them.
3. Print the outcome in a message.

An example would be: Take lable1 as variable x. Take lable2 as variable y. then process as z=x+y. and print z on the page.

View 2 Replies

Query The Database Through A Query String?

Jan 15, 2011

I wanted to create a URL like http://localhost/menu.aspx/?id so that on typing this, it displays all the id's in the database. for eg:134

123

543

234

may be the id's which should be displayed after fetching from the database. However, it should be displayed as it it is without any control or without arranging in any gird etc. How can that be done?

View 1 Replies

Utility To Combine Querystrings?

Apr 28, 2010

Is there a utility to combine querystrings? I'm looking for something like:

Input: Combine("test=a&test2=b", "test3=c") Result: "test=a&test2=b&test3=c"
Input: Combine("test=a&test2=b", "") Result: "test=a&test2=b"
Input: Combine("", "test3=c") Result: "test3=c"

And maybe some weird ones:

Input: Combine("&test=a&test2=b", "?test3=c") Result: "test=a&test2=b&test3=c"

View 5 Replies

ViewState, QueryStrings And Their Effect On SEO?

Oct 7, 2010

I'm a novice ASP.Net/C# programmer, and had an experience only of a couple of projects during college and a couple of freelancing projects when I was recruited by a startup company to build their ASP.Net based website. I've just abut completed the website, and now since the company is not able to find a worthy enough SEO, I'm expected to do our site's SEO as well(which is a totally new experience for me). Did I mention that I'm the only Web Developer here?So, now as you'd expect a novice programmer having no concern for future SEO needs, I built up the site without giving due consideration to any of the SEO enhancement techniques.

The Problems:

ViewState - When is it required? Is it really required if I'm not creating any controls on the fly? I'm using DataControls though. And the website(the pages visible to the user not the CMS), is purely information based. Also, if I disable a control(ex: DataList)'s viewstate, will the viewstate of controls inside it also get disabled?(which is what I'd like actually)QueryStrings - Now comes the toughest part, I've used Query Strings to the extent that you can say that the website is QueryString driven, which unfortunately enough is not a good thing for SEO. To make matters worse, the QueryStrings for some pages are not uniform. For ex- In some cases the querystring may have variables A, B, and C, while in other cases it can have variables M, B, C and probably not all the three variables in some cases. Now, I know that I'd have to do url rewriting but these query strings have dynamic data fetched from the database tables of size more than 10,000 rows. So would I have to create functions for url rewriting and use regex to separate wheat from whaff?

View 1 Replies

Configuration :: Process.start (System.Diagnostics.Process) - Execute A Batch File

Sep 7, 2010

I've written a aspx.net(C#) page that after the user has done what they do on the page they hit a Submit button. The Submit button

1) takes the work the users was producing on the page and writes it to a file.
2) attempts to execute a batch file.

The call to the batch file is executed via:

protected void Execute123EDI()
{
try
{
string File = @"c:80sAdminSendV80s.bat";
lblCancelled.Text = lblCancelled.Text + File;
Process proc = new System.Diagnostics.Process();
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.LoadUserProfile = false;
proc.StartInfo.UserName = "administrator";
proc.StartInfo.RedirectStandardOutput = true;
System.Security.SecureString secPass = new System.Security.SecureString();
string paswd = "123abc";
for (int i = 0; i < paswd.Length; i++)
{
secPass.AppendChar(paswd[i]);
}
proc.StartInfo.Password = secPass;
proc.StartInfo.FileName = File;
proc.Start();
FileStream fs = new FileStream(@"c:80sAdminSendV80sOutput.log", FileMode.Append);
StreamWriter sw = new StreamWriter(fs);
sw.Write(proc.StandardOutput.ReadToEnd());
proc.WaitForExit();
sw.Close();
proc.Close();
}
catch(Exception ex)
{
lblDebug.Text = lblDebug.Text + ex.Message + "<br/>";
}

If I watch the processes tab in Task Manager on the web server I see "cmd.exe" under the context of 'administrator' but it just hangs. For test purposes c:SendV80s.bat: copy c: oot.ini c:zzz.txt

If I logon onto the webserver's console and execute SendV80s.bat it works and exits without issue. But when I execute the same batch file via the Submit button it gets stuck executing in Task Manager/Process. I believe this has something to do with the fact that cmd is not running in a full environment/desktop context. I just noticed this on the actual console of the webserver (not in my RDP console but console 0 instead)

A pop-up box stating: CMD.exe Application error The application failed to initialize properly (0xc0000142). Click OK to terminate the application. And when I click on the OK button my ASPX page's WaitForExit is satisfied and the continues processing normally.

View 2 Replies

URL Routing And QueryStrings In Web Forms Application

Feb 28, 2010

I am trying to implement URL Routing for a non MVC application. Here's my original [URL] to [URL] I have difficulty when the page has query strings in the URL. This is the route handler I have so far:

public class CustomRouteHandler : IRouteHandler
{
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
return BuildManager.CreateInstanceFromVirtualPath("ProcessStuff.aspx", typeof(Page)) as Page;
}
}

View 1 Replies

Security :: Ways Of Encrypting Querystrings?

Sep 8, 2010

I have been looking at ways of encrypting querystrings and I have found a few good examples.. but, I just want some clarification on what is most often referred to as the EncryptionKey and the characters that are in that key....Is there basically an unlimited number of alphanumeric combinations that could be used in the following code as the encryption key, is there anything that someone should be CAREFUL about including in that key?

using System.Security.Cryptography;
private static string EncryptionKey = "!#$a54?3";
/// other examples: "r0b1nr0y"
///in a try-catch:
key = System.Text.Encoding.UTF8.GetBytes(EncryptionKey.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
inputByteArray = Convert.FromBase64String(Input);

View 3 Replies

Using Concat Querystrings Based On Checkbox Selection?

May 5, 2010

i have a querystring like this : Comparison.aspx?id=4545&Product=foo&displaylevelname=128

it's being build by 3 hidden fields in a html tablerow based on checkbox selection.

but user can select multiple checkboxes (20) and afterwards

i need a querystring like this : Comparison.aspx?id=4545&Product=foo&displaylevelname=128;145;455;

So how do i go from :

Comparison.aspx?id=4545&Product=foo&displaylevelname=128

Comparison.aspx?id=4545&Product=foo&displaylevelname=145

Comparison.aspx?id=4545&Product=foo&displaylevelname=455

To Comparison.aspx?id=4545&Product=foo&displaylevelname=128;145;455;

View 4 Replies

Changing QueryStrings In The URL Without Postback / Redirect / Refresh?

Jul 20, 2010

I have a page with some value like this:

[URL]

what I want to do is when the user enters values on the page I want to be able to change "valueA" and "valueB" in the URL without redirecting, refreshing or posingBack. Does anyone know how to do this?

View 7 Replies

Creating Multiple Querystrings From Drop Down Lists?

Feb 19, 2011

I have a gridview which can be filtered from one or more values in a querystring. That all works great: e.g. "?subject=Maths&authorName=Bond_James&type=Magazine"

The values passed to the query string come from 3 drop down lists: Subject, Author, Type. What I'd like is when the user presses "Filter" it will take the selected values from the drop down lists and pass them to the querystring - it could be 1 value, 2, or all 3 (like above).

The drop down lists have an item called "All Subjects" / "All Author" / "All Type" each with a value of -1. The idea being that if the user leaves these items selected then the Filter button just ignores them.

Here is my code so far:

[Code]....

Also, one more thing. How do I get the drop down lists to have the filters selected when the page re loads?

EDIT: I changed the default values of the drop down lists to "" - this leaves the URL looking messy though ?author=&subject=&type= This works, is it the best way?

View 2 Replies

AJAX :: Page Methods Querystrings Are Null?

Oct 20, 2010

I'm having problems with accessing querystring params in my page method. Everywhere I read it says you can access querystrings just fine, but when I try it just returns null, what's the problem?

same problem I found - [URL]

View 14 Replies

HttpHandlers / Modules :: Accessing Querystrings In URL Rewriting?

Nov 15, 2010

I am wanting to develop a URL Rewriting solution that handles postbacks and querystrings. I have found a couple of examples, but don't fully udnerstand the code and don't want to implement code I don't understand. Obviously at the heart of this issue is intercepting the raw url before the rewrite occurs, however, I am not sure exactly how to go about this.

View 4 Replies

Want To Create An Expression For Querystrings, This Stuff Is Hard?

May 7, 2010

I want to extract some keywords out of a query string for a search application in asp.net.I decoded the url string first, so it's plain textI have this to start with, but I want to add a keyword group

([?&])q=[^&]+[&]?

I get this ?q=harbour landing dental&I'd like to trim off the stuff for pure words, but not sure if that's possibleI also have a long list of possible query string value fields that I want to check against

?q=
@q=
?qs=
&qs=

View 2 Replies

C# - Response.redirect Url Encodes Spaces To %20 In Querystrings?

Sep 20, 2010

Response.Redirect("./blah.aspx?key=my value with spaces");

It sends the browser to:

mysite/blah.aspx?key=my%20value%20with%20spaces

Now i understand why it's doing this - for the sake of ancient browsers that would choke on the spaces. But really, what i want is to have a nice-looking url with spaces instead of %'s everywhere, because it works just the same.

Is there some way to stop response.redirect urlencoding my spaces?

View 2 Replies

Passing Values To Another Page From A Gridview Using Querystrings

Apr 4, 2012

I'm trying to use hyperlink fields in my gridview to pass certain values into another page using querystrings. On the next page I've put 'labels' that should be populated with data from the gridview, however nothing happens. This is my gridview code:

"<asp:GridView ID="GridViewGuitars" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSourceGuitars" DataKeyNames="ProductID" BorderColor="White">
<Columns>
<asp:BoundField DataField="ProductID" HeaderText="ProductID"
SortExpression="ProductID" InsertVisible="False" ReadOnly="True"
Visible="False" />

[code]....

And this is the code behind file on the landing page:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

Dim ProdID As String = Request.QueryString("ProductID")
Dim ProdName As String = Request.QueryString("Prod_Name")
Dim ProdPrice As String = Request.QueryString("Prod_Price")
Dim ProdStock As String = Request.QueryString("Prod_Instock")
Dim ProdDescrip As String = Request.QueryString("Prod_Descrip")

[code]....

View 1 Replies

Long Running HTTP Process - How To Put In Separate Process

Jul 21, 2010

I know that similar questions have been asked all over the place, but I'm having trouble finding one that relates directly to what I'm after.

I have a website where a user uploads a data file, then that file is transformed and imported into SQL. The file could be up to 50mb in size, and some times this process can take 30 minutes or sometimes even longer.

I realise I need to palm off the actual work to another process, and poll that process on the web page. I'm wondering what the best approach would be though? Being a web developer by trade, I'm finding all this new Windows Service stuff a bit confusing, and I just wanted somewhere to start.

So:

Can I do / should I being doing this with a windows service? if so, how?

Should I use WCF? If this runs under IIS, will I have problems with aspnet_wp.exe recycling and timing out my process?

clarifications

The data is imported into sql, there's no file distribution taking place.

If there is a failure, it absolutely MUST be reported to the user. The web page will poll every, lets say, 5 seconds, from the time the async task begins, to get the 'status' of the import. Once it's finished another response will tell the page to stop polling for status updates.

queries on final decision

ok, so as I thought, it seems that a windows service is the best idea. So as to HOW to get it to work, it seems the 'put the file there and wait for the service to pick it up' idea is the generally accepted way, is there a way I can start a process run by the service, without it having to constantly be checking a database table / folder? As I said earlier, I don't have any experience with Windows Services - I wondered if I put a public method in the service, can I call it somehow?

View 2 Replies

Execute A Process Remotely With System.Diagnostics.Process

Feb 26, 2010

I'm working on an ASP.net app I'm trying to execute a process remotely , using System.Diagnostics.Process class here's my code:

ProcessStartInfo startInfo = new ProcessStartInfo(@"C:TestCommand.exe");
startInfo.Domain = "myDomain";
startInfo.UserName = "MyUserName";
SecureString sec = new SecureString();
foreach (char item in "MyPassword")
{
sec.AppendChar(item);
}
sec.MakeReadOnly();
startInfo.Password = sec;
startInfo.UseShellExecute = false;
Process.Start(startInfo);

I keep receiving an exception with the message "Logon failure: unknown user name or bad password". Im absolutelly sure that i'm submiting my correct username/pwd

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved