Showing posts with label particular. Show all posts
Showing posts with label particular. Show all posts

Thursday, March 22, 2012

Trouble with QueryString

Hi,
I access a particular page by specifying the page's name and extension like
so:
http://localhost:xxxx/MyFiles/Lucky/
The Lucky directory contains a webpage named Default.aspx. I can access is
without needing to type in the page's name and
extension. This page uses a querystring and is only specified when needed (
e.g. keywords=sam). My trouble is that if I
access the page without specifying the page's name and extension, somehow th
e querystring is given a value on its own.
Debugging reveals that the querystring contains the value of "default.aspx"
What could be causing this issue? I've been at this for a few hours now wit
h no luck. Any help would be greatly appreciated.
Thanks,
RoshawnRoshawn,
Are you doing any URL rewriting or redirection? I've seen this
before when doing redirection and not filtering out the default page as a
possible value.
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199...2006
"Roshawn" <radawson218@.yahoo.com> wrote in message
news:%2374iTQNRHHA.2124@.TK2MSFTNGP06.phx.gbl...
> Hi,
> I access a particular page by specifying the page's name and extension
> like so:
> http://localhost:xxxx/MyFiles/Lucky/
> The Lucky directory contains a webpage named Default.aspx. I can access
> is without needing to type in the page's name and extension. This page
> uses a querystring and is only specified when needed (e.g. keywords=sam).
> My trouble is that if I access the page without specifying the page's name
> and extension, somehow the querystring is given a value on its own.
> Debugging reveals that the querystring contains the value of
> "default.aspx"
> What could be causing this issue? I've been at this for a few hours now
> with no luck. Any help would be greatly appreciated.
> Thanks,
> Roshawn
Hmm, you're absolutely right!
I am doing URL rewriting, using Regex of course. I discovered that one of m
y Regex rules was incorrect. That's what was
causing the trouble as I wasn't filtering out the default page.
Thanks for the help, :-)
Roshawn
Mark Fitzpatrick wrote:
> Roshawn,
> Are you doing any URL rewriting or redirection? I've seen this
> before when doing redirection and not filtering out the default page as a
> possible value.
>

Trouble with QueryString

Hi,

I access a particular page by specifying the page's name and extension like so:

http://localhost:xxxx/MyFiles/Lucky/
The Lucky directory contains a webpage named Default.aspx. I can access is without needing to type in the page's name and
extension. This page uses a querystring and is only specified when needed (e.g. keywords=sam). My trouble is that if I
access the page without specifying the page's name and extension, somehow the querystring is given a value on its own.
Debugging reveals that the querystring contains the value of "default.aspx"

What could be causing this issue? I've been at this for a few hours now with no luck. Any help would be greatly appreciated.

Thanks,
RoshawnRoshawn,
Are you doing any URL rewriting or redirection? I've seen this
before when doing redirection and not filtering out the default page as a
possible value.

--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"Roshawn" <radawson218@.yahoo.comwrote in message
news:%2374iTQNRHHA.2124@.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

Hi,
>
I access a particular page by specifying the page's name and extension
like so:
>
http://localhost:xxxx/MyFiles/Lucky/
>
The Lucky directory contains a webpage named Default.aspx. I can access
is without needing to type in the page's name and extension. This page
uses a querystring and is only specified when needed (e.g. keywords=sam).
My trouble is that if I access the page without specifying the page's name
and extension, somehow the querystring is given a value on its own.
Debugging reveals that the querystring contains the value of
"default.aspx"
>
What could be causing this issue? I've been at this for a few hours now
with no luck. Any help would be greatly appreciated.
>
Thanks,
Roshawn


Hmm, you're absolutely right!

I am doing URL rewriting, using Regex of course. I discovered that one of my Regex rules was incorrect. That's what was
causing the trouble as I wasn't filtering out the default page.

Thanks for the help, :-)
Roshawn

Mark Fitzpatrick wrote:

Quote:

Originally Posted by

Roshawn,
Are you doing any URL rewriting or redirection? I've seen this
before when doing redirection and not filtering out the default page as a
possible value.
>

Trouble with Radiobuttons

Hi,

I am working on this project of creating webforms and this one particular page has a bunch of radiobuttons in it. Once the user clicks one of the radiobuttons and then clicks on submit, the user is redirected to a different webform. In the event handler for the submit button, I check to see if that one particular radiobutton has been clicked or not ,kinda like this below:

privatevoid InitializeComponent()

{

this.submit_button.Click +=new System.EventHandler(this.submit_button_Click);

}

privatevoid submit_button_Click(object sender, System.EventArgs e)

{

if (radiobutton1.Checked ==true)

{

Response.Redirect("page1.aspx");

}

The problem is when I check radiobutton1 and then click submit, nothing happens and I stay on the same page. I ran the debugger and it didn't even step through the code. Can anyone help me out here?

Try this - uses both types of radio button/list

<%@.PageLanguage="C#" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<scriptrunat="server">

protectedvoid RadioButton3_CheckedChanged(object sender,EventArgs e)

{

Response.Redirect("Default.aspx?Fruit=" + Server.HtmlEncode(((RadioButton)sender).Text));

}

protectedvoid RadioButtonList1_SelectedIndexChanged(object sender,EventArgs e)

{

Response.Redirect("Default.aspx?Fruit=" + Server.HtmlEncode(RadioButtonList1.SelectedValue));

}

</script>

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Untitled Page</title>

</head>

<body>

<formid="form1"runat="server">

<div>

<asp:RadioButtonID="RadioButton1"runat="server"GroupName="RB1"Text="Apples"OnCheckedChanged="RadioButton3_CheckedChanged"/>

<asp:RadioButtonID="RadioButton2"runat="server"GroupName="RB1"Text="Oranges"

OnCheckedChanged="RadioButton3_CheckedChanged"/>

<asp:RadioButtonID="RadioButton3"runat="server"GroupName="RB1"Text="Gone Bananas"

OnCheckedChanged="RadioButton3_CheckedChanged"/>

</div>

<div>

<asp:RadioButtonListID="RadioButtonList1"runat="server"OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">

<asp:ListItem>Pears</asp:ListItem>

<asp:ListItem>Cherries</asp:ListItem>

<asp:ListItem>WinkleBerry</asp:ListItem>

</asp:RadioButtonList>

</div>

<asp:LinkButtonID="LinkButton1"runat="server">Submit</asp:LinkButton>

</form>

</body>

</html>


Thanks for the response...I am working with .aspx files...So instead of embedding scripts like you suggested, I have to write backend code in the .aspx.cs files..Its just that after I click on the submit button it should hit that part of the code where I have the event handler in case the submit button is clicked. I still can't figure out why its not doing that...I am working on a visual studio 2003 platform

Tuesday, March 13, 2012

Troubles sending email with System.Net.Mail (ASP.NET 2.0)

Hi All,

I am having difficulties sending an email from a web page that I created to my own email. This particular web pages is suppose to be a feedback form where people can leave feedback about the site and it should send the message to my email. The Exception message I get is: "Failure sending mail." Here is the piece of code I use to handle the email sending. If anyone can shed some light on this issue, it would be greatly appreciated :)

protectedvoid btnSubmit_Click(object sender,EventArgs e)

{

try

{

SmtpClient emailClient =newSmtpClient();

MailMessage email =newMailMessage();

emailClient.Host ="localhost";

emailClient.Port = 25;

email.To.Add(newMailAddress("kevintrinh.n@dotnet.itags.org.gmail.com"));

email.From =newMailAddress(txtEmail.Text);

email.Subject ="Enquiry";

email.Body ="Testing";

email.IsBodyHtml =false;

emailClient.Send(email);

}

catch(Exception ex)

{

Response.Write(ex.Message);

}

}

Cheers guys

Check the SMTP logs to start troubleshooting this.

Jeff


You'll need more detailed error info to get help.

One quick thing to check, is antivirus software on your computer blocking your code from sending email?


I have a feedback page, too, and it works great. Here's my code:

The Click Event:

public void SendMail_Click(object sender, EventArgs e)

{

SendMail();

}


public void SendMail()
{
//create the mail message
MailMessage mail = new MailMessage();

//set the addresses
mail.From = new MailAddress(WebConfigurationManager.AppSettings["DefaultMailFrom"], "Internet User: " + txtName.Text);
mail.To.Add(WebConfigurationManager.AppSettings["DefaultMailTo"]);
if (txtEmail.Text.Trim() != "")
mail.ReplyTo = new MailAddress(txtEmail.Text.Trim());

//set the content
mail.Subject = txtSubject.Text;
mail.Body = txtBody.Text;
mail.Body += "\n\nReferring page: " + lnkReferrerF.NavigateUrl;

//send the message
SmtpClient smtp = new SmtpClient(WebConfigurationManager.AppSettings["DefaultMailServer"]);
smtp.Send(mail);
}

And then under <AppSettings> in the web.config file I have:

<add key="DefaultMailFrom" value="mailer@.site.com" />
<add key="DefaultMailReplyTo" value="david@.site.com" />
<add key="DefaultMailTo" value="david@.site.com" />

<add key="DefaultMailServer" value="mailserver name" />

Hope this helps.


Kevin-

If you're currently trying to run this on your local PC, make sure you have an SMTP server running on your box. Open up the IIS Configuration in your Control Panel > Administrative Tools and make sure the Default SMTP Virtual Server is started.

Thanks~


Hi everyone,

Thanks for all the insight...I really appreciate it. I will take a look at all your suggestions and follow up. Thanks again guys :)

Cheers


Dear Friend,

Also check out if you are running any anti virus scanners. Sometimes those applications blocks the port for sending out the emails. You may need to configure them to send out the emails.


tanglin05:

Kevin-

If you're currently trying to run this on your local PC, make sure you have an SMTP server running on your box. Open up the IIS Configuration in your Control Panel > Administrative Tools and make sure the Default SMTP Virtual Server is started.

Thanks~

Hi Todd,

I think this is my problem. I've taken a look on the net and all the tutorials explain the procedure to configure the virtual smtp server for all windows other than VISTA. Just wondering if you know how to configure the settings on vista or if you/anyone know of any links that may point me in the right direction?
In the mean time I will continue looking for explanations online :)

Thanks mate.


Kevin-

I'm away from my desktop right now, so I don't have Vista handy. Based on these posts I found on the Net, it appears SMTP may not be in Vista (?!):

http://tfl09.blogspot.com/2007/03/smtp-in-vista-or-not.html

http://weblogs.asp.net/steveschofield/archive/2006/12/19/iis7-post-23-vista-and-smtp-server-where-is-it.aspx

I can't verify this right now, so if anyone knows otherwise please correct me. The links I provided have references to shareware SMTP servers that you can install to solve your problem, so this may help you get on your way.

Thanks~


Todd you're a champ mate...I downloaded a free smtp server and it sends nowBig Smile');" title="Big Smile -Big Smile">

Just some tips for anyone else with a similar problem. If you are trying to send emails from you local machine, make sure the ISP you are going through does not block port 25 (else your emails cannot be sent). I found that I could send from uni but I couldn't send from home (for the above reason)

If everything seems ok with your code and server setup however you do not receive any emails.....check your SPAM folder!! (This is also what happened to me; spent 2 long hours trying to work out why I wasn't receiving any emails!)

I found the following SMTP server application to be the most useful one out there as it allows you to test whether port 25 is open. You can download the free 30day trial here1st SMTP Server

Hope this helps anyone facing the same email problems as I didSmile');" title="Smile -Smile">

Thanks again everyone for your helpYes');" title="Yes -Yes">