Showing posts with label method. Show all posts
Showing posts with label method. Show all posts

Saturday, March 24, 2012

Permission Problem writing to Disk in Asp.NET application

Here's what I need to do:
Due to a bug in Crystal Reports ExportToStream() method I can't stream a
Crystal Reports directly to the client as PDF and I must must use the
Export() and put the the PDF on disk first and stream to the client. That's
just how it is.

Question:
So I need to let the aspx user have write permissions to disk.. NOT GOOD.
How do I solve this? Can I somehow write the PDF to disk in another thread
with other writes? OR are ther other ways around this?

best regards
/Lars NetzelLars

Note : The code below is stripped from a asp.net project using a web
service. This project would relay a binary file from an internal web server
where Crystal reports is installed to an external web server. You will still
need write permissions for the directory you want to save to

You could try this, I hope It helps

Stream fs =
rep.ExportToStream(CrystalDecisions.Shared.ExportF ormatType.PortableDocFormat);
byte[] binaryfile = StreamToBinary(fs);
string docLocation = Server.MapPath(null) + @."\Docs\";
SaveFileToServer(binaryfile,docLocation,"my.pdf",DateTime.Now);
Response.Redirect("Docs/"+"my.pdf");

public void SaveFileToServer(byte[] binaryFile, string docPath, string
docName, DateTime fileModifiedDate)
{
Directory.CreateDirectory(docPath);
MemoryStream m = new MemoryStream(binaryFile);
FileStream f = new FileStream(docPath+docName,FileMode.Create);
m.WriteTo(f);
f.Close();
m.Close();
File.SetLastWriteTime(docPath+docName,fileModified Date);
}

public byte[] StreamToBinary(Stream fs)
{
Int32 i = Convert.ToInt32(fs.Length);
byte[] b = new byte[fs.Length];
fs.Read(b,0,i);
fs.Close();
}

"Lars Netzel" <lars.netzel@.NO-SPAM.qlogic.se> wrote in message
news:%23wlKhu8HFHA.3244@.TK2MSFTNGP09.phx.gbl...
> Here's what I need to do:
> Due to a bug in Crystal Reports ExportToStream() method I can't stream a
> Crystal Reports directly to the client as PDF and I must must use the
> Export() and put the the PDF on disk first and stream to the client.
> That's just how it is.
> Question:
> So I need to let the aspx user have write permissions to disk.. NOT GOOD.
> How do I solve this? Can I somehow write the PDF to disk in another thread
> with other writes? OR are ther other ways around this?
> best regards
> /Lars Netzel
Thanks but I can't ExportToStream due to a bug with record and
groupselections in the Crystal Reports Engine. so I can't use that code.

I need to write to disk with other permisisons than the ASPNET user

/Lars

"Kamal Vaghjiani" <kamal@.mortgageuk.com> wrote in message
news:Ok7aI59HFHA.2784@.TK2MSFTNGP09.phx.gbl...
> Lars
> Note : The code below is stripped from a asp.net project using a web
> service. This project would relay a binary file from an internal web
> server where Crystal reports is installed to an external web server. You
> will still need write permissions for the directory you want to save to
> You could try this, I hope It helps
> Stream fs =
> rep.ExportToStream(CrystalDecisions.Shared.ExportF ormatType.PortableDocFormat);
> byte[] binaryfile = StreamToBinary(fs);
> string docLocation = Server.MapPath(null) + @."\Docs\";
> SaveFileToServer(binaryfile,docLocation,"my.pdf",DateTime.Now);
> Response.Redirect("Docs/"+"my.pdf");
> public void SaveFileToServer(byte[] binaryFile, string docPath, string
> docName, DateTime fileModifiedDate)
> {
> Directory.CreateDirectory(docPath);
> MemoryStream m = new MemoryStream(binaryFile);
> FileStream f = new FileStream(docPath+docName,FileMode.Create);
> m.WriteTo(f);
> f.Close();
> m.Close();
> File.SetLastWriteTime(docPath+docName,fileModified Date);
> }
> public byte[] StreamToBinary(Stream fs)
> {
> Int32 i = Convert.ToInt32(fs.Length);
> byte[] b = new byte[fs.Length];
> fs.Read(b,0,i);
> fs.Close();
> }
>
> "Lars Netzel" <lars.netzel@.NO-SPAM.qlogic.se> wrote in message
> news:%23wlKhu8HFHA.3244@.TK2MSFTNGP09.phx.gbl...
>> Here's what I need to do:
>> Due to a bug in Crystal Reports ExportToStream() method I can't stream a
>> Crystal Reports directly to the client as PDF and I must must use the
>> Export() and put the the PDF on disk first and stream to the client.
>> That's just how it is.
>>
>> Question:
>> So I need to let the aspx user have write permissions to disk.. NOT GOOD.
>> How do I solve this? Can I somehow write the PDF to disk in another
>> thread with other writes? OR are ther other ways around this?
>>
>> best regards
>> /Lars Netzel
>>

Permission Problem writing to Disk in Asp.NET application

Here's what I need to do:
Due to a bug in Crystal Reports ExportToStream() method I can't stream a
Crystal Reports directly to the client as PDF and I must must use the
Export() and put the the PDF on disk first and stream to the client. That's
just how it is.
Question:
So I need to let the aspx user have write permissions to disk.. NOT GOOD.
How do I solve this? Can I somehow write the PDF to disk in another thread
with other writes? OR are ther other ways around this?
best regards
/Lars NetzelLars
Note : The code below is stripped from a asp.net project using a web
service. This project would relay a binary file from an internal web server
where Crystal reports is installed to an external web server. You will still
need write permissions for the directory you want to save to
You could try this, I hope It helps
Stream fs =
rep.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocForma
t);
byte[] binaryfile = StreamToBinary(fs);
string docLocation = Server.MapPath(null) + @."\Docs\";
SaveFileToServer(binaryfile,docLocation,
"my.pdf",DateTime.Now);
Response.Redirect("Docs/"+"my.pdf");
public void SaveFileToServer(byte[] binaryFile, string docPath, string
docName, DateTime fileModifiedDate)
{
Directory.CreateDirectory(docPath);
MemoryStream m = new MemoryStream(binaryFile);
FileStream f = new FileStream(docPath+docName,FileMode.Create);
m.WriteTo(f);
f.Close();
m.Close();
File. SetLastWriteTime(docPath+docName,fileMod
ifiedDate);
}
public byte[] StreamToBinary(Stream fs)
{
Int32 i = Convert.ToInt32(fs.Length);
byte[] b = new byte[fs.Length];
fs.Read(b,0,i);
fs.Close();
}
"Lars Netzel" <lars.netzel@.NO-SPAM.qlogic.se> wrote in message
news:%23wlKhu8HFHA.3244@.TK2MSFTNGP09.phx.gbl...
> Here's what I need to do:
> Due to a bug in Crystal Reports ExportToStream() method I can't stream a
> Crystal Reports directly to the client as PDF and I must must use the
> Export() and put the the PDF on disk first and stream to the client.
> That's just how it is.
> Question:
> So I need to let the aspx user have write permissions to disk.. NOT GOOD.
> How do I solve this? Can I somehow write the PDF to disk in another thread
> with other writes? OR are ther other ways around this?
> best regards
> /Lars Netzel
>
Thanks but I can't ExportToStream due to a bug with record and
groupselections in the Crystal Reports Engine. so I can't use that code.
I need to write to disk with other permisisons than the ASPNET user
/Lars
"Kamal Vaghjiani" <kamal@.mortgageuk.com> wrote in message
news:Ok7aI59HFHA.2784@.TK2MSFTNGP09.phx.gbl...
> Lars
> Note : The code below is stripped from a asp.net project using a web
> service. This project would relay a binary file from an internal web
> server where Crystal reports is installed to an external web server. You
> will still need write permissions for the directory you want to save to
> You could try this, I hope It helps
> Stream fs =
> rep.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFor
mat);
> byte[] binaryfile = StreamToBinary(fs);
> string docLocation = Server.MapPath(null) + @."\Docs\";
> SaveFileToServer(binaryfile,docLocation,
"my.pdf",DateTime.Now);
> Response.Redirect("Docs/"+"my.pdf");
> public void SaveFileToServer(byte[] binaryFile, string docPath, string
> docName, DateTime fileModifiedDate)
> {
> Directory.CreateDirectory(docPath);
> MemoryStream m = new MemoryStream(binaryFile);
> FileStream f = new FileStream(docPath+docName,FileMode.Create);
> m.WriteTo(f);
> f.Close();
> m.Close();
> File. SetLastWriteTime(docPath+docName,fileMod
ifiedDate);
> }
> public byte[] StreamToBinary(Stream fs)
> {
> Int32 i = Convert.ToInt32(fs.Length);
> byte[] b = new byte[fs.Length];
> fs.Read(b,0,i);
> fs.Close();
> }
>
> "Lars Netzel" <lars.netzel@.NO-SPAM.qlogic.se> wrote in message
> news:%23wlKhu8HFHA.3244@.TK2MSFTNGP09.phx.gbl...
>

permission to File.Exists

Hi,
In my Web Application, I need to check whether a file exists. I'm using the
System.IO.File.Exists("filename") method.
This file is in another server.
Always the return's method is False. But through the windows explorer I have
permission to access it. So Can I do?
thanks a lot
Marcos SantosMost likely the default ASPNET user account does not have network security
privileges.
To test this theory, use impersonation to have the web application run under
your user account.
Here's more info:
http://msdn.microsoft.com/library/d...personation.asp
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Marcos MOS" <marcos.santos@.softway.com.br> wrote in message
news:%23$SvPoPSEHA.2408@.tk2msftngp13.phx.gbl...
> Hi,
> In my Web Application, I need to check whether a file exists. I'm using
the
> System.IO.File.Exists("filename") method.
> This file is in another server.
> Always the return's method is False. But through the windows explorer I
have
> permission to access it. So Can I do?
> thanks a lot
> Marcos Santos
>

permission to File.Exists

Hi,

In my Web Application, I need to check whether a file exists. I'm using the
System.IO.File.Exists("filename") method.
This file is in another server.
Always the return's method is False. But through the windows explorer I have
permission to access it. So Can I do?

thanks a lot
Marcos SantosMost likely the default ASPNET user account does not have network security
privileges.
To test this theory, use impersonation to have the web application run under
your user account.
Here's more info:
http://msdn.microsoft.com/library/d...personation.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Marcos MOS" <marcos.santos@.softway.com.br> wrote in message
news:%23$SvPoPSEHA.2408@.tk2msftngp13.phx.gbl...
> Hi,
> In my Web Application, I need to check whether a file exists. I'm using
the
> System.IO.File.Exists("filename") method.
> This file is in another server.
> Always the return's method is False. But through the windows explorer I
have
> permission to access it. So Can I do?
> thanks a lot
> Marcos Santos

Wednesday, March 21, 2012

Perplexity on relation over a select count

I need to get the child of parent/child relation and I've some perplexity
about the best method to use.
The classic (select count(*) id from table where id = a.parentid) nested
into a select generate a lot of
roundrip if used for a large set of results, but for small search is quite
good.
But what about the new ado.net relation table? Is more efficient? What does
it do internally?
Take on mind that I'm working over a 2003 access database, so the choice
cannot use SP as well as complex results set that return table object that
SQL server can return.
Thank you
Andreaperhaps you should post your question to one of the 'ms access' forums. You
may have better luck.
-- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"andrea" <googlegroups@.freemail.it> wrote in message
news:9fa0d7351833f8c812a7cff697bc@.news.microsoft.com...
>I need to get the child of parent/child relation and I've some perplexity
>about the best method to use.
> The classic (select count(*) id from table where id = a.parentid) nested
> into a select generate a lot of
> roundrip if used for a large set of results, but for small search is quite
> good.
> But what about the new ado.net relation table? Is more efficient? What
> does it do internally?
> Take on mind that I'm working over a 2003 access database, so the choice
> cannot use SP as well as complex results set that return table object that
> SQL server can return.
> Thank you
> Andrea
>
>

Perplexity on relation over a select count

I need to get the child of parent/child relation and I've some perplexity
about the best method to use.

The classic (select count(*) id from table where id = a.parentid) nested
into a select generate a lot of
roundrip if used for a large set of results, but for small search is quite
good.

But what about the new ado.net relation table? Is more efficient? What does
it do internally?

Take on mind that I'm working over a 2003 access database, so the choice
cannot use SP as well as complex results set that return table object that
SQL server can return.

Thank you
Andreaperhaps you should post your question to one of the 'ms access' forums. You
may have better luck.

--
-- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"andrea" <googlegroups@.freemail.it> wrote in message
news:9fa0d7351833f8c812a7cff697bc@.news.microsoft.c om...
>I need to get the child of parent/child relation and I've some perplexity
>about the best method to use.
> The classic (select count(*) id from table where id = a.parentid) nested
> into a select generate a lot of
> roundrip if used for a large set of results, but for small search is quite
> good.
> But what about the new ado.net relation table? Is more efficient? What
> does it do internally?
> Take on mind that I'm working over a 2003 access database, so the choice
> cannot use SP as well as complex results set that return table object that
> SQL server can return.
> Thank you
> Andrea

Friday, March 16, 2012

persistence of variables in an aspx page...

If I have a code-behind page that loads a bunch of data into variables in the Page_Load method, will the variables keep their data for that particular instance of the page? For instance, if I have:

private string userid;
// ...
public void Page_Load(..)
{
userid = Request.QueryString["ID"];
}

and the user does some input on the web form and then submits the page, will the "userid" variable still contain the data I put in it during the Page_Load method? If so, does that work for all objects (like DataSets, etc.)? If not, will I have to put the "userid" data into a session variable instead?Request.QueryString["ID"] will persist across all postbacks, but the userID variable will not. You'll need to reload that variable each time, or put it in viewstate the first time.
I was just using the querystring as an example; I realize that particular value will persist, but that fact is negligable in the overall scope of my question. Regardless, you answered it. If I put such variables in ViewState, how long will they remain there? Will they be destroyed when the page is closed? Can I store larger objects in viewstate, such as DataSets? Thanks!
The viewstate remains for the life of the page, so, unstill it's navigated away from.

You could certainly put a dataset in there, but I wouldn't recommend it. Viewstate is stored as a hidden form field on the page, so, you'd be serializing kilobytes of additional data and sending it to the client as payload.
Ah, I completely forgot about that. You're absolutely right. Guess I'll have to find another way around it. Thanks!