Showing posts with label via. Show all posts
Showing posts with label via. Show all posts

Monday, March 26, 2012

Serial Port access

I am using VS2005 C# to create an ASP.Net application involving accessing a device in a packing machine via Serial Port.

I am trying using DataReceived event of SerialPort class to read the data from Serial Port in the web page, but I am having the problem on reading the data back and not sure how to do.

By reading from forums, I learned that server created a secondary thread for Serial Comm.

Anyone with any idea, please help.

Thanks.

waitingCrying


Hi mwang,

I think you can use the winforms sample for serial port accessing in ASP.NET. But need to take care of the identity and security setting.

Thursday, March 22, 2012

Serve up file from outside web application directory

I come from a ColdFusion background, and CF has the ability (via something
called CFCONTENT) which allows you to serve up a file which resides outside
your web root directory.
How do I accomplish a similar thing using ASP.net 2 (C#)?
Basically, my web app is creating a PDF document and storing it in C:\PDFS
In my app, I want to have a LinkButton which will serve up the PDF (located
in C:\PDFS) to the user.
I DO NOT want to have the PDFs in the web app's directory structure because
you have to log into the app to use it. And I don't want just anyone to be
able to link to the PDF.
Thanks in advance for any advice,
BrianCold Fusion, ha good times there.
In C# you would use something like
DirectoryInfo dir = new DirectoryInfo("c:\\pdfFiles);
FileInfo[] pdfFiles= dir.GetFiles("*.pdf");
foreach(FileInfo f in pdfFiles)
{
Response.Write("<br><a href="http://links.10026.com/?link= + f.Name + ">" + f.Name + "</a>");
}
"Brian Simmons" <centraso@.newsgroup.nospam> wrote in message
news:%23c5n%23jB4HHA.4672@.TK2MSFTNGP05.phx.gbl...
>I come from a ColdFusion background, and CF has the ability (via something
>called CFCONTENT) which allows you to serve up a file which resides outside
>your web root directory.
> How do I accomplish a similar thing using ASP.net 2 (C#)?
> Basically, my web app is creating a PDF document and storing it in C:\PDFS
> In my app, I want to have a LinkButton which will serve up the PDF
> (located in C:\PDFS) to the user.
> I DO NOT want to have the PDFs in the web app's directory structure
> because you have to log into the app to use it. And I don't want just
> anyone to be able to link to the PDF.
> Thanks in advance for any advice,
> Brian
>
http://support.microsoft.com/kb/306654
Rather than using MapPath, just supply the actual directory.
"Brian Simmons" <centraso@.newsgroup.nospam> wrote in message
news:%23c5n%23jB4HHA.4672@.TK2MSFTNGP05.phx.gbl...
>I come from a ColdFusion background, and CF has the ability (via something
>called CFCONTENT) which allows you to serve up a file which resides outside
>your web root directory.
> How do I accomplish a similar thing using ASP.net 2 (C#)?
> Basically, my web app is creating a PDF document and storing it in C:\PDFS
> In my app, I want to have a LinkButton which will serve up the PDF
> (located in C:\PDFS) to the user.
> I DO NOT want to have the PDFs in the web app's directory structure
> because you have to log into the app to use it. And I don't want just
> anyone to be able to link to the PDF.
> Thanks in advance for any advice,
> Brian
>
Also ignore the "Add the PDF File to the Project" section :) As you want
the file outside your web space
"Aidy" <aidy@.xxnoemailxx.com> wrote in message
news:iKGdnaUWU_Dw7lnbnZ2dnUVZ8sqjnZ2d@.bt
.com...
> http://support.microsoft.com/kb/306654
> Rather than using MapPath, just supply the actual directory.
> "Brian Simmons" <centraso@.newsgroup.nospam> wrote in message
> news:%23c5n%23jB4HHA.4672@.TK2MSFTNGP05.phx.gbl...
>
Hi Brian,
This is a piece of cake in ASP.NET since you can utlize the powerful
functionality of .net framework components. As other members have
suggested, you can use the System.IO classes to get binary data from the
external file system (even on remote share folder) and write it out to
page's response stream. e.g.
======================
protected void Page_Load(object sender, EventArgs e)
{
byte[] bytes = null;
string path = @."d:\filestore\pdf_files\test.pdf";
bytes = File.ReadAllBytes(path);
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType= "application\pdf";
Response.AddHeader("Content-disposition", "attachment;
filename=test.pdf");
Response.Write(bytes);
Response.End();
}
===========
Here is a web article also mentioned this:
#Secure File Download Page
http://www.codeproject.com/aspnet/S...ileDownload.asp
In addition, you can even get the file content from other storage such as
database, webservice .... It's quite flexible when you use the .net
frameowork classes to deal with the things:)
Hope this also helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Serve SSL via HttpModule?

I have an IIS 6.0 web server that does not have an SSL certificate set
up on the web site.
Is it possible to enable SSL via my ASP.NET 2.0 web application only by
inserting the SSL handshake, etc in an Http Module or anywhere else in
the ASP.NET pipeline? For example, I could then offer different certs
based on the Request uri, etc.
Thaks.no, you would need to write an iis filer in c/c++.
not sure the point. SSL certificates are tied to the domain name, and iis
already supports cerificates per domain.
-- bruce (sqlwork.com)
<bradwiseathome@.hotmail.com> wrote in message
news:1150916949.181236.176100@.b68g2000cwa.googlegroups.com...
>I have an IIS 6.0 web server that does not have an SSL certificate set
> up on the web site.
> Is it possible to enable SSL via my ASP.NET 2.0 web application only by
> inserting the SSL handshake, etc in an Http Module or anywhere else in
> the ASP.NET pipeline? For example, I could then offer different certs
> based on the Request uri, etc.
> Thaks.
>
The point is that the site is reachable as www.mysite.com and
mysite.com and www2.mysite.com. If there is a server-installed cert for
www.mysite.com, the user gets the confusing cert-prompt. If the cert
handling was in .NET, then I could respond with the appropriate
certificate based on the contents of the Request.
bruce barker (sqlwork.com) wrote:
> no, you would need to write an iis filer in c/c++.
> not sure the point. SSL certificates are tied to the domain name, and iis
> already supports cerificates per domain.
>
> -- bruce (sqlwork.com)
>
>
>
> <bradwiseathome@.hotmail.com> wrote in message
> news:1150916949.181236.176100@.b68g2000cwa.googlegroups.com...
bradwiseathome@.hotmail.com wrote:
> The point is that the site is reachable as www.mysite.com and
> mysite.com and www2.mysite.com. If there is a server-installed cert for
> www.mysite.com, the user gets the confusing cert-prompt. If the cert
> handling was in .NET, then I could respond with the appropriate
> certificate based on the contents of the Request.
Then purchase a wildcard SSL certificate.
PL.
There is no way in doing this in ASP.NET 2.0 because as previously
posted, the request once reach the IIS then only it will be handled
against the SSL request then given to the ASP.NET handlers.
So, there is no escape other than buying an SSL certificate

Serve SSL via HttpModule?

I have an IIS 6.0 web server that does not have an SSL certificate set
up on the web site.

Is it possible to enable SSL via my ASP.NET 2.0 web application only by
inserting the SSL handshake, etc in an Http Module or anywhere else in
the ASP.NET pipeline? For example, I could then offer different certs
based on the Request uri, etc.

Thaks.no, you would need to write an iis filer in c/c++.

not sure the point. SSL certificates are tied to the domain name, and iis
already supports cerificates per domain.

-- bruce (sqlwork.com)

<bradwiseathome@.hotmail.com> wrote in message
news:1150916949.181236.176100@.b68g2000cwa.googlegr oups.com...
>I have an IIS 6.0 web server that does not have an SSL certificate set
> up on the web site.
> Is it possible to enable SSL via my ASP.NET 2.0 web application only by
> inserting the SSL handshake, etc in an Http Module or anywhere else in
> the ASP.NET pipeline? For example, I could then offer different certs
> based on the Request uri, etc.
> Thaks.
The point is that the site is reachable as www.mysite.com and
mysite.com and www2.mysite.com. If there is a server-installed cert for
www.mysite.com, the user gets the confusing cert-prompt. If the cert
handling was in .NET, then I could respond with the appropriate
certificate based on the contents of the Request.

bruce barker (sqlwork.com) wrote:
> no, you would need to write an iis filer in c/c++.
> not sure the point. SSL certificates are tied to the domain name, and iis
> already supports cerificates per domain.
>
> -- bruce (sqlwork.com)
>
>
>
> <bradwiseathome@.hotmail.com> wrote in message
> news:1150916949.181236.176100@.b68g2000cwa.googlegr oups.com...
> >I have an IIS 6.0 web server that does not have an SSL certificate set
> > up on the web site.
> > Is it possible to enable SSL via my ASP.NET 2.0 web application only by
> > inserting the SSL handshake, etc in an Http Module or anywhere else in
> > the ASP.NET pipeline? For example, I could then offer different certs
> > based on the Request uri, etc.
> > Thaks.
bradwiseathome@.hotmail.com wrote:
> The point is that the site is reachable as www.mysite.com and
> mysite.com and www2.mysite.com. If there is a server-installed cert for
> www.mysite.com, the user gets the confusing cert-prompt. If the cert
> handling was in .NET, then I could respond with the appropriate
> certificate based on the contents of the Request.

Then purchase a wildcard SSL certificate.

PL.
There is no way in doing this in ASP.NET 2.0 because as previously
posted, the request once reach the IIS then only it will be handled
against the SSL request then given to the ASP.NET handlers.

So, there is no escape other than buying an SSL certificate

Tuesday, March 13, 2012

Server Application Unavailable

Hi all!
I have a ASP.NET application written in C#.
I connect this app with a 4th Dimension database via ODBC.
My problem is that when i try to fill a dataset and the query dont return
any data, I get an "Server Application Unavailable"-error.
Is there a way to catch this error? Ive tried with try/catch,
application_error in global.asax and CustomErrors="On"
defaultRedirect="errorpage.aspx" but none of those can handle this error.
Does anyone knows something about this?
/MarreHi Marre,
Do you have access to the event log on this machine? That error usually
writes useful information to the event log.
"MA" <news@..removethis.supremelink.se> wrote in message
news:36edkkF4vg6l3U1@.individual.net...
> Hi all!
> I have a ASP.NET application written in C#.
> I connect this app with a 4th Dimension database via ODBC.
> My problem is that when i try to fill a dataset and the query dont return
> any data, I get an "Server Application Unavailable"-error.
>
> Is there a way to catch this error? Ive tried with try/catch,
> application_error in global.asax and CustomErrors="On"
> defaultRedirect="errorpage.aspx" but none of those can handle this error.
> Does anyone knows something about this?
> /Marre
>