Showing posts with label system. Show all posts
Showing posts with label system. Show all posts

Monday, March 26, 2012

PerformanceCounter / System Up Time / TimeSpan

Hi all,
I'm having a bit of trouble with the following function...
Private Function GetSystemUpTime() As TimeSpan
' declare variables
Dim Result As TimeSpan
Dim PerformanceCounter As PerformanceCounter
' create new instances of our objects
PerformanceCounter = New PerformanceCounter("System", "System Up Time")
' populate
Result = TimeSpan.FromSeconds(PerformanceCounter.NextValue())
' return result
Return Result
End Function
For some reason I keep getting the value 0 (zero) for days, hours,minutes,
seconds etc - ie, I've tried this on 2 machines now and the result is always
the same. I've tried other counters using a similar method (for available
memory,application restarts etc) and they do come through...
Can anyone shed any light on this for me...
PS: I've had a bit of a look online and I'm aware of the environment.tick
thing but that has a problem over a value of 24 (goes to minus numbers) so
would prefer to use a PerformanceCounter object.
Regards
RobThe first call always returns zero, apparently... see the page here:
http://www.sitepoint.com/forums/pri...ad.php?t=376778
Regards,
Brett.
Rob Meade wrote:
> Hi all,
> I'm having a bit of trouble with the following function...
> Private Function GetSystemUpTime() As TimeSpan
> ' declare variables
> Dim Result As TimeSpan
> Dim PerformanceCounter As PerformanceCounter
> ' create new instances of our objects
> PerformanceCounter = New PerformanceCounter("System", "System Up Time"
)
> ' populate
> Result = TimeSpan.FromSeconds(PerformanceCounter.NextValue())
> ' return result
> Return Result
> End Function
> For some reason I keep getting the value 0 (zero) for days, hours,minutes,
> seconds etc - ie, I've tried this on 2 machines now and the result is alwa
ys
> the same. I've tried other counters using a similar method (for available
> memory,application restarts etc) and they do come through...
> Can anyone shed any light on this for me...
> PS: I've had a bit of a look online and I'm aware of the environment.tick
> thing but that has a problem over a value of 24 (goes to minus numbers) so
> would prefer to use a PerformanceCounter object.
> Regards
> Rob
"Brett Wiltshire" wrote ...

> The first call always returns zero, apparently... see the page here:
> http://www.sitepoint.com/forums/pri...ad.php?t=376778
Hi Bretty,
Thanks for your reply - you know - in the example I saw that had this code
it actually said about that - I assumed - clearly wrongly - that the
"NextValue()" thing meant - go get the next one because the first one is
always zero...
*sigh*
That's taken up 2 hours of my day searching the net just for a
misunderstanding :o(
Anyway, many thanks for your reply - I've for now just duplicated the line
that gets it and it works fine :o)
Thanks
Rob

PerformanceCounter / System Up Time / TimeSpan

Hi all,

I'm having a bit of trouble with the following function...

Private Function GetSystemUpTime() As TimeSpan

' declare variables
Dim Result As TimeSpan
Dim PerformanceCounter As PerformanceCounter

' create new instances of our objects
PerformanceCounter = New PerformanceCounter("System", "System Up Time")

' populate
Result = TimeSpan.FromSeconds(PerformanceCounter.NextValue( ))

' return result
Return Result

End Function

For some reason I keep getting the value 0 (zero) for days, hours,minutes,
seconds etc - ie, I've tried this on 2 machines now and the result is always
the same. I've tried other counters using a similar method (for available
memory,application restarts etc) and they do come through...

Can anyone shed any light on this for me...

PS: I've had a bit of a look online and I'm aware of the environment.tick
thing but that has a problem over a value of 24 (goes to minus numbers) so
would prefer to use a PerformanceCounter object.

Regards

RobThe first call always returns zero, apparently... see the page here:
http://www.sitepoint.com/forums/pri...ad.php?t=376778

Regards,
Brett.

Rob Meade wrote:
> Hi all,
> I'm having a bit of trouble with the following function...
> Private Function GetSystemUpTime() As TimeSpan
> ' declare variables
> Dim Result As TimeSpan
> Dim PerformanceCounter As PerformanceCounter
> ' create new instances of our objects
> PerformanceCounter = New PerformanceCounter("System", "System Up Time")
> ' populate
> Result = TimeSpan.FromSeconds(PerformanceCounter.NextValue( ))
> ' return result
> Return Result
> End Function
> For some reason I keep getting the value 0 (zero) for days, hours,minutes,
> seconds etc - ie, I've tried this on 2 machines now and the result is always
> the same. I've tried other counters using a similar method (for available
> memory,application restarts etc) and they do come through...
> Can anyone shed any light on this for me...
> PS: I've had a bit of a look online and I'm aware of the environment.tick
> thing but that has a problem over a value of 24 (goes to minus numbers) so
> would prefer to use a PerformanceCounter object.
> Regards
> Rob
"Brett Wiltshire" wrote ...

> The first call always returns zero, apparently... see the page here:
> http://www.sitepoint.com/forums/pri...ad.php?t=376778

Hi Bretty,

Thanks for your reply - you know - in the example I saw that had this code
it actually said about that - I assumed - clearly wrongly - that the
"NextValue()" thing meant - go get the next one because the first one is
always zero...

*sigh*

That's taken up 2 hours of my day searching the net just for a
misunderstanding :o(

Anyway, many thanks for your reply - I've for now just duplicated the line
that gets it and it works fine :o)

Thanks

Rob
Anyone know if its possible to pull the same information from different
machines on the network?

A new instance of PerformanceCounter seems to be able to take a machine
name - but I've tried this and get access denied errors...

I guess i some how need to be able to tell the servers in question that the
ASP.Net process model is allowed to access this?

Any ideas anyone?

My other thought was as a web service, so I have one page which drags the
info from the other servers, this would of course then rely on IIS being
present, not so good for my clustered SQL Servers! Open to suggestions...

Regards

Rob

Permalinks

Hello,

I am creating a simple Asp.Net Blog system. All blog posts have an ID which is an unique identifier (a GUID).

Now I wanna create permalinks. What format should I use? How can I do this?

Could someone, please, help me out?

Thanks,

Miguel

What's a permalink and what is it supposed to do?

Hi,

A permalink is a redefinition of the url in an easier way for a user to read or identify it.

Check http://en.wikipedia.org/wiki/Permalink

For example a blog post with such an url:

http://www.mydomain.com/post.aspx?id=398179823223

would become something like:

http://www.mydomain.com/<4 digit year>/<2 digit month>/<2 digit day>/<article name>/

This would show the post with id=398179823223

I don't know exactly how to implement this in my ASP.NET web site.

Thanks,

Miguel


Hi,

A permalink is a redefinition of the url in an easier way for a user to read or identify it.

Check http://en.wikipedia.org/wiki/Permalink

For example a blog post with such an url:

http://www.mydomain.com/post.aspx?id=398179823223

would become something like:

http://www.mydomain.com/<4 digit year>/<2 digit month>/<2 digit day>/<article name>/

This would show the post with id=398179823223

I don't know exactly how to implement this in my ASP.NET web site.

Thanks,

Miguel


Hi shapper,

Forgive me cuz i'm not familiar with this "permanent link" and what i suggested may be wrong. I searched thru the internet and found the following informaton. i hope it can be helpful to solve your problems anyway.

"With Ajaxium it is easy to construct permanent links which guide exactly to the page opened. So if the ASP.NET page is accessible for the visitor by a link, it is just as accessible when Ajaxium is enabled." (Orignial Article see:http://www.ajaxium.com/ajax-critique.aspx) So, could you try to impliment it using AJAX?

Hope my suggestion helps . thanks :)

Permalinks

Hello,
I am creating a simple Asp.Net Blog system. All blog posts have an ID
which is an unique identifier (a GUID).
Now I wanna create permalinks. What format should I use? How can I do
this?
Could someone, please, help me out?
Thanks,
MiguelTry :
http://en.wikipedia.org/wiki/Permalink and especially the "Popular permalink
formats" chapter.
This is likely most often done suign URL rewriting :
http://en.wikipedia.org/wiki/URL_rewriting
Patrice
"shapper" <mdmoura@.gmail.com> a crit dans le message de news:
1177340457.202371.125940@.l77g2000hsb.googlegroups.com...
> Hello,
> I am creating a simple Asp.Net Blog system. All blog posts have an ID
> which is an unique identifier (a GUID).
> Now I wanna create permalinks. What format should I use? How can I do
> this?
> Could someone, please, help me out?
> Thanks,
> Miguel
>
Hi,
Patrice wrote:
> Try :
> http://en.wikipedia.org/wiki/Permalink and especially the "Popular permali
nk
> formats" chapter.
> This is likely most often done suign URL rewriting :
> http://en.wikipedia.org/wiki/URL_rewriting
Why sue URL rewriting? What did it do to you? :-)
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Depending on the format used it can be a convenient way to map the permalink
to the actual page. For example the OP could parse all year/month/title.aspx
permalinks so that they all map to a default.aspx?id=someid request...
"Laurent Bugnion, MVP" <galasoft-lb@.bluewin.ch> a crit dans le message de
news: %23tbhMkjhHHA.4588@.TK2MSFTNGP02.phx.gbl...
> Hi,
> Patrice wrote:
> Why sue URL rewriting? What did it do to you? :-)
> Laurent
> --
> Laurent Bugnion [MVP ASP.NET]
> Software engineering, Blog: http://www.galasoft-LB.ch
> PhotoAlbum: http://www.galasoft-LB.ch/pictures
> Support children in Calcutta: http://www.calcutta-espoir.ch
Hi,
Patrice wrote:
> Depending on the format used it can be a convenient way to map the permali
nk
> to the actual page. For example the OP could parse all year/month/title.as
px
> permalinks so that they all map to a default.aspx?id=someid request...
Yes. I was trying to make a joke *S* Nevermind!
Greetings,
Laurent

> "Laurent Bugnion, MVP" <galasoft-lb@.bluewin.ch> a crit dans le message de
> news: %23tbhMkjhHHA.4588@.TK2MSFTNGP02.phx.gbl...
>
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch

Permalinks

Hello,

I am creating a simple Asp.Net Blog system. All blog posts have an ID
which is an unique identifier (a GUID).

Now I wanna create permalinks. What format should I use? How can I do
this?

Could someone, please, help me out?

Thanks,

MiguelTry :
http://en.wikipedia.org/wiki/Permalink and especially the "Popular permalink
formats" chapter.

This is likely most often done suign URL rewriting :
http://en.wikipedia.org/wiki/URL_rewriting
--
Patrice

"shapper" <mdmoura@.gmail.coma crit dans le message de news:
1177340457.202371.125940@.l77g2000hsb.googlegroups. com...

Quote:

Originally Posted by

Hello,
>
I am creating a simple Asp.Net Blog system. All blog posts have an ID
which is an unique identifier (a GUID).
>
Now I wanna create permalinks. What format should I use? How can I do
this?
>
Could someone, please, help me out?
>
Thanks,
>
Miguel
>


Hi,

Patrice wrote:

Quote:

Originally Posted by

Try :
http://en.wikipedia.org/wiki/Permalink and especially the "Popular permalink
formats" chapter.
>
This is likely most often done suign URL rewriting :
http://en.wikipedia.org/wiki/URL_rewriting


Why sue URL rewriting? What did it do to you? :-)

Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Depending on the format used it can be a convenient way to map the permalink
to the actual page. For example the OP could parse all year/month/title.aspx
permalinks so that they all map to a default.aspx?id=someid request...

"Laurent Bugnion, MVP" <galasoft-lb@.bluewin.cha crit dans le message de
news: %23tbhMkjhHHA.4588@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Hi,
>
Patrice wrote:

Quote:

Originally Posted by

>Try :
>http://en.wikipedia.org/wiki/Permalink and especially the "Popular
>permalink formats" chapter.
>>
>This is likely most often done suign URL rewriting :
>http://en.wikipedia.org/wiki/URL_rewriting


>
Why sue URL rewriting? What did it do to you? :-)
>
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch


Hi,

Patrice wrote:

Quote:

Originally Posted by

Depending on the format used it can be a convenient way to map the permalink
to the actual page. For example the OP could parse all year/month/title.aspx
permalinks so that they all map to a default.aspx?id=someid request...


Yes. I was trying to make a joke *S* Nevermind!

Greetings,
Laurent

Quote:

Originally Posted by

>
"Laurent Bugnion, MVP" <galasoft-lb@.bluewin.cha crit dans le message de
news: %23tbhMkjhHHA.4588@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>Hi,
>>
>Patrice wrote:

Quote:

Originally Posted by

>>Try :
>>http://en.wikipedia.org/wiki/Permalink and especially the "Popular
>>permalink formats" chapter.
>>>
>>This is likely most often done suign URL rewriting :
>>http://en.wikipedia.org/wiki/URL_rewriting


>Why sue URL rewriting? What did it do to you? :-)
>>
>Laurent
>--
>Laurent Bugnion [MVP ASP.NET]
>Software engineering, Blog: http://www.galasoft-LB.ch
>PhotoAlbum: http://www.galasoft-LB.ch/pictures
>Support children in Calcutta: http://www.calcutta-espoir.ch


>
>


--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch

Saturday, March 24, 2012

Permission Issue

I am trying to test some aspx pages on my local system. The code requires a
"db" directory off the root of the web site. In my Inetpub/myproj I added
the directory but cannot figure out how to give the application authority to
write into that directory. I get the error:

System.UnauthorizedAccessException: Access to the path
"c:\inetpub\wwwroot\OfficeApp\db\judgedata.csv" is denied.

In the error information it says to grant ASP.NET write access to a file,
right-click the file in Explorer, choose "Properties" and select the
Security tab. There is no "Security" tab. I must be missing something here?
How do I set that directory to allow asp.net to write to it?

Wayne"Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
news:uaqU3wViFHA.3568@.TK2MSFTNGP10.phx.gbl...

> Security tab. There is no "Security" tab. I must be missing something
> here?

Uncheck the "Use simple file sharing" (bottom option) in the "View" tab of
the "Folder Options" dialog.

John
Thanks for the suggestion but after doing that I still get the same error?

Wayne

"WJ" <JohnWebbs@.HotMail.Com> wrote in message
news:eTlcryWiFHA.1460@.tk2msftngp13.phx.gbl...
> "Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
> news:uaqU3wViFHA.3568@.TK2MSFTNGP10.phx.gbl...
>> Security tab. There is no "Security" tab. I must be missing something
>> here?
> Uncheck the "Use simple file sharing" (bottom option) in the "View" tab of
> the "Folder Options" dialog.
> John
"Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
news:OV5Ov3WiFHA.1148@.TK2MSFTNGP12.phx.gbl...

> Thanks for the suggestion but after doing that I still get the same error?

This only lets you use the "Security" tab on the Windows Explorer. To fix
the error (access denied), you must grant r/w access to the account that
runs your website to the database file where your data resides.

John
John;

Thanks for the clarification. I did that and gave ASP.NET full control of
that directory but it still gives the same error when the code attempts to
create a file in that directory?

Wayne

"WJ" <JohnWebbs@.HotMail.Com> wrote in message
news:Og0ICGXiFHA.3544@.TK2MSFTNGP15.phx.gbl...
> "Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
> news:OV5Ov3WiFHA.1148@.TK2MSFTNGP12.phx.gbl...
>> Thanks for the suggestion but after doing that I still get the same
>> error?
>>
> This only lets you use the "Security" tab on the Windows Explorer. To fix
> the error (access denied), you must grant r/w access to the account that
> runs your website to the database file where your data resides.
> John
"Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
news:%233bhDRXiFHA.3280@.TK2MSFTNGP10.phx.gbl...
> John;
> Thanks for the clarification. I did that and gave ASP.NET full control of
> that directory but it still gives the same error when the code attempts to
> create a file in that directory?

Check your local website (IIS/MMC) to find out what account is configured
for the web site, then grant FC to that account. Example: If you allow
"Anonymous" access to the web site, then the User Account box likely shows
"IUSR_YourPCName". Try that see what happens.

John
"Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
news:%233bhDRXiFHA.3280@.TK2MSFTNGP10.phx.gbl...
> John;
> Thanks for the clarification. I did that and gave ASP.NET full control of
> that directory but it still gives the same error when the code attempts to
> create a file in that directory?

Check your local website (IIS/MMC) to find out what account is configured
for the web site, then grant FC to that account. Example: If you allow
"Anonymous" access to the web site, then the User Account box likely shows
"IUSR_YourPCName". Try that see what happens.

John
John;

Thanks for the continued help. I am not sure how to determine which account
is configured for the web site (I thought ASP.NET was always used by VSNET
projects?) I went to Control Panel/Administrative Tools/IIS and Properties
but I don't see how to determine the default user for a web site?

Wayne

"WJ" <JohnWebbs@.HotMail.Com> wrote in message
news:eJobGXXiFHA.3936@.TK2MSFTNGP10.phx.gbl...
> "Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
> news:%233bhDRXiFHA.3280@.TK2MSFTNGP10.phx.gbl...
>> John;
>>
>> Thanks for the clarification. I did that and gave ASP.NET full control of
>> that directory but it still gives the same error when the code attempts
>> to create a file in that directory?
>>
> Check your local website (IIS/MMC) to find out what account is configured
> for the web site, then grant FC to that account. Example: If you allow
> "Anonymous" access to the web site, then the User Account box likely shows
> "IUSR_YourPCName". Try that see what happens.
> John
Hi, Wayne.

This all boils down to giving the account ASP.NET is running
under, *whichever account that is* the necessary permissions.

If you have doubts about which account ASP.NET is running under,
just run this short script. It will identify ASP.NET's current identity.

identity.aspx
----
<%@. Page Language="VB" %>
<%@. Import NameSpace = System.Security.Principal %>
<script runat="server">
Sub Page_Load()
Dim tmp As String = WindowsIdentity.GetCurrent.Name()
Label1.Text = tmp
End Sub
</script>
<html>
<head>
<title>WindowsIdentity.GetCurrent.Name()</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" Runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
---

Hope this helps...

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espaol
Ven, y hablemos de ASP.NET...
======================

"Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
news:uAtm5ffiFHA.3448@.TK2MSFTNGP12.phx.gbl...
> John;
> Thanks for the continued help. I am not sure how to determine which account is
> configured for the web site (I thought ASP.NET was always used by VSNET projects?) I
> went to Control Panel/Administrative Tools/IIS and Properties but I don't see how to
> determine the default user for a web site?
> Wayne
> "WJ" <JohnWebbs@.HotMail.Com> wrote in message
> news:eJobGXXiFHA.3936@.TK2MSFTNGP10.phx.gbl...
>>
>> "Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
>> news:%233bhDRXiFHA.3280@.TK2MSFTNGP10.phx.gbl...
>>> John;
>>>
>>> Thanks for the clarification. I did that and gave ASP.NET full control of that
>>> directory but it still gives the same error when the code attempts to create a file in
>>> that directory?
>>>
>>
>> Check your local website (IIS/MMC) to find out what account is configured for the web
>> site, then grant FC to that account. Example: If you allow "Anonymous" access to the
>> web site, then the User Account box likely shows "IUSR_YourPCName". Try that see what
>> happens.
>>
>> John
>>
>>
Juan;

Thanks for that page. That is a handy little tool to have. It revealed that
the account used is "myMachine/ASPNET" (no ".") I gave that FC but it still
gives me the erron on my local machine - it works fine on my real web site.

Wayne

"Juan T. Llibre" <nomailreplies@.nowhere.com> wrote in message
news:eVXEvCgiFHA.1444@.TK2MSFTNGP10.phx.gbl...
> Hi, Wayne.
> This all boils down to giving the account ASP.NET is running
> under, *whichever account that is* the necessary permissions.
> If you have doubts about which account ASP.NET is running under,
> just run this short script. It will identify ASP.NET's current identity.
> identity.aspx
> ----
> <%@. Page Language="VB" %>
> <%@. Import NameSpace = System.Security.Principal %>
> <script runat="server">
> Sub Page_Load()
> Dim tmp As String = WindowsIdentity.GetCurrent.Name()
> Label1.Text = tmp
> End Sub
> </script>
> <html>
> <head>
> <title>WindowsIdentity.GetCurrent.Name()</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <asp:Label ID="Label1" Runat="server" Text="Label"></asp:Label>
> </div>
> </form>
> </body>
> </html>
> ---
> Hope this helps...
>
> Juan T. Llibre
> ASP.NET MVP
> http://asp.net.do/foros/
> Foros de ASP.NET en Espaol
> Ven, y hablemos de ASP.NET...
> ======================
> "Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
> news:uAtm5ffiFHA.3448@.TK2MSFTNGP12.phx.gbl...
>> John;
>>
>> Thanks for the continued help. I am not sure how to determine which
>> account is configured for the web site (I thought ASP.NET was always used
>> by VSNET projects?) I went to Control Panel/Administrative Tools/IIS and
>> Properties but I don't see how to determine the default user for a web
>> site?
>>
>> Wayne
>>
>> "WJ" <JohnWebbs@.HotMail.Com> wrote in message
>> news:eJobGXXiFHA.3936@.TK2MSFTNGP10.phx.gbl...
>>>
>>> "Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
>>> news:%233bhDRXiFHA.3280@.TK2MSFTNGP10.phx.gbl...
>>>> John;
>>>>
>>>> Thanks for the clarification. I did that and gave ASP.NET full control
>>>> of that directory but it still gives the same error when the code
>>>> attempts to create a file in that directory?
>>>>
>>>
>>> Check your local website (IIS/MMC) to find out what account is
>>> configured for the web site, then grant FC to that account. Example: If
>>> you allow "Anonymous" access to the web site, then the User Account box
>>> likely shows "IUSR_YourPCName". Try that see what happens.
>>>
>>> John
>>>
>>>
>>
>>