Showing posts with label whenever. Show all posts
Showing posts with label whenever. Show all posts

Wednesday, March 28, 2012

System.Media.SystemSounds not playing

The title is only half true, which is the thing that confuses me.

In my code behind, I am calling

System.Media.SystemSounds.Hand.Play();

whenever there is an incorrect input from the user. This works perfectly when I run it locally on my machine, but when I upload it to the server and run it from the website, the page works exactly the same except that there is no sound played. I've tried this with System.Media.SoundPlayer as well to the same effect. I'm doing the tests from the same computer. I've also remoted into the server and tried it there with no sound playing. The server is Windows Server 2003, running the project in Framework 2.0.

Does anyone know why this is a problem?

it's playing - on the server

as you said - you have it in the code-behind, which is executed on the server.

You would need something client-side to play through client browser.

Not sure how to do that


Aha, that's the problem. Thanks for that!

Just to test it, I ran IIS off of my computer and let some people make my computer ding repeatedly. I believe they enjoyed it far too much. I just tried embedding the Play() method in the .aspx file, but that doesn't work either.

I'm thinking I'll have to do some client-side scripting of some javascript in there. Something like

<%

if (bError)

{

%>

_javascript_

<%

}

I don't know a way to make a sound without a dialog box, however. I'll do some searching.


if you find the solution - post so others may benefit

mark the post as answered please....

Monday, March 26, 2012

System.Net HttpWebRequest - post a form

(Type your message here)
From: senthil t
There is a third party website that we use=2E Whenever someone=
unsubscribes from our website, some one has to go to that third=
party website, enter the unsubscribed user info and submit the=
form=2E We are doing this manually=2E What I would like is, whenever=
any user unsubscribes from our website, auto post the third=
party website form with all the user information from my =2Enet=
code=2E This is the code I have right now=2E But this is not=
working=2E
HttpWebRequest webRequest =3D (HttpWebRequest) WebRequest=2ECreate=
(URL);
webRequest=2EKeepAlive =3D false;
webRequest=2ETimeout =3D 100000;
webRequest=2EMethod =3D "POST";
webRequest=2EContentType =3D "application/x-www-form-urlencoded";
byte[] requestBytes =3D (new=
System=2EText=2EASCIIEncoding())=2EGetBy
tes (PostData);
webRequest=2EContentLength =3D requestBytes=2ELength;
Stream requestStream =3D webRequest=2EGetRequestStream();
requestStream=2EWrite (requestBytes, 0, requestBytes=2ELength);
requestStream=2EClose();
webResponse =3D (HttpWebResponse) webRequest=2EGetResponse();
sr =3D new StreamReader (webResponse=2EGetResponseStream(),=
System=2EText=2EEncoding=2EASCII);
response =3D sr=2EReadToEnd ();
With =2Easpx page, it was not doing anything until I added the=
viewstate info to the postdata=2E But is throwing an error at this=
line=2E
webResponse =3D (HttpWebResponse) webRequest=2EGetResponse();
Internal Server Error=2ESystem=2ENet=2EHttpWebResponse at=
System=2ENet=2EHttpWebRequest=2ECheckFin
alStatus() at=
System=2ENet=2EHttpWebRequest=2EEndGetRe
sponse(IAsyncResult=
asyncResult) at System=2ENet=2EHttpWebRequest=2EGetRespo
nse()
Can any one tell me what is wrong with what I am doing?
Posted by a user from =2ENET 247 (http://www=2Edotnet247=2Ecom/)
<Id>0ZTNUiUrPECOfo+INVokdg=3D=3D</Id>Hi senthil:
What I've done in the past is use a tool like Fiddler [1] to compare
what my program is POSTing to the server versus what happens when I
use a browser.
http://www.fiddlertool.com/fiddler/
Scott
http://www.OdeToCode.com/blogs/scott/
On Sun, 15 May 2005 05:03:55 -0700, senthil t via .NET 247
<anonymous@.dotnet247.com> wrote:

>(Type your message here)
>--
>From: senthil t
>There is a third party website that we use. Whenever someone unsubscribes from our
website, some one has to go to that third party website, enter the unsubscribed user
info and submit the form. We are doing this manually. What I would like is, wheneve
r a
ny user unsubscribes from our website, auto post the third party website form with all the
user information from my .net code. This is the code I have right now. But this is not work
ing.
> HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create (URL);
> webRequest.KeepAlive = false;
> webRequest.Timeout = 100000;
> webRequest.Method = "POST";
> webRequest.ContentType = "application/x-www-form-urlencoded";
> byte[] requestBytes = (new System.Text.ASCIIEncoding()).GetBytes (PostDa
ta);
> webRequest.ContentLength = requestBytes.Length;
> Stream requestStream = webRequest.GetRequestStream();
> requestStream.Write (requestBytes, 0, requestBytes.Length);
> requestStream.Close();
> webResponse = (HttpWebResponse) webRequest.GetResponse();
> sr = new StreamReader (webResponse.GetResponseStream(), System.Text.Enco
ding.ASCII);
> response = sr.ReadToEnd ();
>With .aspx page, it was not doing anything until I added the viewstate info
to the postdata. But is throwing an error at this line.
>webResponse = (HttpWebResponse) webRequest.GetResponse();
>Internal Server Error.System.Net.HttpWebResponse at System.Net.HttpWebReque
st.CheckFinalStatus() at System.Net.HttpWebRequest.EndGetResponse(IAsyncResu
lt asyncResult) at System.Net.HttpWebRequest.GetResponse()
>Can any one tell me what is wrong with what I am doing?
>--
>Posted by a user from .NET 247 (http://www.dotnet247.com/)
><Id>0ZTNUiUrPECOfo+INVokdg==</Id>