I'm using urlRewritingNet. My web.config is here>>
<add name="HOME" virtualUrl="^~/(.*)/Default.aspx" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/Default.aspx?PageTitle=$1" ignoreCase="true"/>
My query string is here:
www.domain.com/home/default.aspx
This works. But I'm insert LoginStatus control. When click on the login control to logout, Page url was like this www.domain.com/home/default.aspx?PageTitle=home
Request.Querystring["PageTitle"] result is home,home
How to stop this duplicated query string?
I came across the same problem, I did something like following;
change your destinationUrl to "~/Default.aspx/$1"
and catch it with Request.PathInfo.Substring(1);
Related
I'am using intelligencia.UrlRewriter on my web site.
I'am sending two querystring parameter to profil page.
<asp:HyperLink ID="lnkProfil" runat="server" Text='profil' NavigateUrl='/u/9f51e845-1089-4495-bd66-964db5b9c47b/tiju' ForeColor="Silver"></asp:HyperLink>
web config :
<rewrite url="~/u/(.+)/(.+)" to="~/Profil.aspx?user_id=$1&user_name=$2" />
and url seems like
http://yxyx.com/u/9f51e845-1089-4495-bd66-964db5b9c47b/tiju
But I want to make like
http://yxyx.com/u/tiju
or directly
http://yxyx.com/tiju (like facebook & twitter)
How can I hide user id parameter on url ?
If you want to have http://yxyx.com/u/tiju you should set it in the HyperLink
<asp:HyperLink ... NavigateUrl='/u/tiju' ...
In this case rewrite rule could be as
<rewrite url="~/u/(.+)" to="~/Profil.aspx?user_name=$1" />
As you see, in this case you will send only one parameter (tiju)
I have text box that allows the user to enter something which is stored in the database, and then another text box which retrieves this value from the database and displays it. Currently, I have something like this:
string text = Server.HTMLDecode(userEnteredText);
//code to put this text into the database
Textbox1.Text = Server.HTMLDecode(textFromDatabase);
The Server.HTMLDecode solves any problems encountered if a user enters the ' char.
However, I noticed if a user enters "'" into the textbox, then ASP gives a error again thinking the client is entering potentially dangerous text. Is there anyway around this? I notice on most sites that this is automatically turned into a apostrophe. Any idea how I do this to avoid user input problems?
If you're sure you want this, then set this in your web.config:
<system.web>
<httpRuntime requestValidationMode="2.0" />
<pages validateRequest="false" />
</system.web>
I have a field with nvarchar datatype to store UNICODE value. This field is bound to Repeater Control from which i am redirecting to other page on clicking the link. When this field contains the numeric value in field then, i get the correct QueryString and it displays the Redirected page. But, When it contains some unicode charater(Other than Number or English Character) then it show the value '?????' in QueryString of 'fhn'. How to get this UNICODE QueryString value as it is and display result?
In Repeater ItemTemplate:
<b>घर क्र./House No.</b><%# Eval("HouseNumber")%>
या पत्यावरील
In .cs file:
string HouseNumber = Request.QueryString["fhn"].ToString().Trim();
//here i get the '????' value if it contains unicode value.
Help appreciated!
Try changing it to something more like this:
<!-- Web.Config Configuration File -->``<configuration>
<system.web>
<customErrors mode="Off"/>
<globalization fileEncoding="iso-8859-1" requestEncoding="iso-8859-1"responseEncoding="iso-8859-1"/>
</system.web>
</configuration>
You'll have to be a more precise. You could set request and response encoding in your web.config file:
<system.web>
<globalization requestEncoding="iso-8859-1" responseEncoding="iso-8859-1" />
</system.web>
I am using IIS7 and urlMappings to map some urls to actual pages.
Example:
<urlMappings>
<!-- Remap friendly urls to actual pages: -->
<add url="~/help/" mappedUrl="~/content/help/help.aspx" />
<add url="~/news/" mappedUrl="~/content/news/default.aspx" />
</urlMappings>
This works great if the url has a trailing '/' , example:
http://www.mysite.com/news/
But I get page not found error if I do this:
http://www.mysite.com/news
I could add an extra entry without the trailing '/' so that both map to the same page, but I don't want to do this for SEO (would think it is duplicate content).
Is it possible to get the urlMappings to redirect?
For example, something like this:
<add url="~/help" redirect="~/help/" />
If not, what would be the best way of doing this?
Do you think google would really penalize
http://www.mysite.com/news/
http://www.mysite.com/news
as duplicate?
Here is my work around:
I add both entries, with and without trailing '/', to the urlMappings in web.config
<urlMappings>
<!-- Remap friendly urls to actual pages: -->
<add url="~/help/" mappedUrl="~/content/help/help.aspx" />
<add url="~/help" mappedUrl="~/content/help/help.aspx" />
</urlMappings>
Then in the page itself add the following code on page_load:
Dim mappedUrl as string = "/help"
If Request.RawUrl.EndsWith(mappedUrl) Then
Response.RedirectPermanent(String.Format("~{0}/", mappedUrl))
End If
This will permanently redirect and calls to the mapped page without a trailing '/' to the same page with a trailing '/'
I have a web form to submit a new user details. In that for password field, a textbox is used.
Validation is required for that as 'it shold contain min 8 characters with atleast one non-alphanumeric character'. I'm providing validation for it in web config file as:-
<membership defaultProvider="SQLMembershipProvider">
<providers>
<remove name="SQLMembershipProvider"/>
<add name="SQLMembershipProvider" connectionStringName="DAFEConnection" minRequiredPasswordLength="8" minRequiredNonalphanumericCharacters="1" type="System.Web.Security.SqlMembershipProvider" applicationName="WBCPDA" requiresQuestionAndAnswer="false" enablePasswordReset="true" maxInvalidPasswordAttempts="4" passwordAttemptWindow="15" requiresUniqueEmail="true"/>
</providers>
</membership>
This validation is triggered on server side, i.e. when I click 'submit' button.
I WANT TO VALIDATE THE SAME AT CLIENT-SIDE, i.e. as soon as he enters a non-desired value in text-box.
PLZ help
The quickest way to do this would be using a Regular Expression Validator. See documentation here.
Kangkan's suggestion is very good; not only the idea to use jQuery for this; but mostly the idea of using a regular expression to validate that the password is in the expected format.
Additional answer:
It's difficult The quickest way to give you exact code that will work for your case since you didn't provide markup; but you could do something similar to this :
<asp:button id="btnSubmit" runat="server" OnClientClick="return validate_pass();" OnClick="YourHandler" />
And would be using a javascript function .Regular Expression Validator. See documentation here.
function validate_pass()
{
//txtPassword is assumed to be the id of the password text field on your page
var passField = document.getElementById('<%=txtPassword.ClientID%>');
if(passField.value.length<8)
{
alert('Password must contain at least 8 characters');
return false;
}
return true;
}
You can use javascript or jQuery plugins to check for the password rules in the client side. You can refer to http://plugins.jquery.com/plugin-tags/password-validation or http://bassistance.de/jquery-plugins/jquery-plugin-password-validation/. You may even roll out your own javascript code and use RegEx to validate.