How to get Complete QueryString? [closed] - c#

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
How can I get complete querystring in asp.net?
Suppose a QueryString like this passed to my Login Page.
login.aspx?redirect=cart.aspx&p=1&q=2&r=3
I have to pass parameters p,q and r to Cart.aspx with all of the parameters except redirect.
Login.aspx may handle different querystrings but all parameters except the redirect are to be passed to the redirecting page.(Actually, I know there will be a parameter 'redirect' but can't write code for p,q,and r bcoz it may change in different contexts)
The parameters except 'redirect' will be different in different contexts. The p,q,r are required parameters for cart.aspx. If the redirection is to another page then the parameters may not be p,q,r instead something else like l,m,n

You can use like this
Request.Url.Query
Input like this
Input: http://localhost:96/Cambia3/Temp/Test.aspx?q=item#fragment
Output

You can get the parameters using
string _url=Request.RawUrl.toString();
and
For path ...
string _path = Request.Path.ToString();
string _url = Request.ServerVariables["URL"].ToString();
O/P = /Home/About/
RawURl Returns whole querystring....

Related

C# CodeDom Cant type in " [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I want to compile a code with codedom which should connect to my ftp server.
But I cant type in the credentials because of the ""...
Look here :
Temp.AppendLine(#"request.Credentials = new NetworkCredential("userid","userpassword");");
If I type " in the code, it automatic ends the content of the brackets...
Help?
You may need to escape the content by using double quotes, like this:
Temp.AppendLine(#"request.Credentials = new NetworkCredential(""userid"",""userpassword"");");
Temp.AppendLine(#"request.Credentials = new NetworkCredential(""userid"",""userpassword"");");
Escape the " with ""

How can I get from a string of a directory and file name only the file name? [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
The code:
'Files' is a List<string> and _indx is an int.
label22.Text = files[_indx];
For example in 'files' in index[0] I have this string:
D:\New folder (45)\converted.avi_Automatic\Lightning 0 Length 2 [91 - 93]\000091.bmp
But instead in label22.Text I want it to show me only '000091.bmp' without the rest of the directory path.
How can I do it ?
Use Path.GetFileName:
label22.Text = Path.GetFileName(files[_indx]);
I believe you are looking for Path.GetFileName():
label22.Text = Path.GetFileName(files[_indx]);
Path.GetFileName(fileName) returns the file name without the directory.
taken from http://msdn.microsoft.com/en-us/library/system.io.path.getfilename(v=vs.100).aspx
The simplest way is
Path.GetFileName(files[_indx]);

what does format {0:x} mean? [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I came across this C# literal and was wondering what does it mean?
Especially, in the following case:
string.Format("{0:x}", byteArray[i]);
Thanks
It means format the first argument (index 0) as hexadecimal: http://msdn.microsoft.com/en-us/library/s8s7t687(v=vs.80).aspx
It means the first argument will be output as hexadecimal (in lowercase !!).
To output uppercase you could use "{0:X}".
Look msdn for more info about string formatting : MSDN Custom string format
This represents the hexadecimal format.

Conditional record type with FileHelpers [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 11 years ago.
I'm trying to parse a file using the Filehelpers library. My file looks like this:
000001,"A",123,456
000002,"B","ABC","XYZ"
000003,"B","DEF","XYZ"
000004,"B","HIJ","XYZ"
My file contains rows that have different column definitions, where the 'type' of row is defined by the character in the second column. i.e. In the sample above I have an "A" row followed by three "B" rows.
Filehelpers requires that I pass the CLR type used to define a row when I instantiate the file helpers engine, or us the generic version as below.
FileHelperEngine<ARecord> engine = new FileHelperEngine<ARecord>()
This means I'm restricted to a single type to define every row in my file.
Is there any way I can parse a file like this and conditionally specify the record type based on a part of the given row?
found it. http://www.filehelpers.com/example_multirecords.html

C# check line number of stringreader [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
How do I check if the string reader has passed a certain line number, or has passed a line number which contains some text? I put this in the line processing code of a string reader:
if (currentline.Contains("123"))
currentbank = "123";
else if (currentline.Contains("456"))
currentbank = "456";
else if (currentline.Contains("789"))
currentbank = "789";
I want to change the contents of a string based on what range of line numbers it is in, with my code it always gives 123. Like for example if it's from lines 10-20 (or from 123 to 456) then the string should have 123, 20-30 (or 456 to 789) it should have 456 and 30-40 have 789. How can I do this using a StringReader?
Fixed it myself, problem being I used upper case (e.g. TEST) instead of lower case.

Categories