safely read computer name from asp.net

  • Thread starter Thread starter Stefano
  • Start date Start date
S

Stefano

Hi all,

how can I safely retrieve computer name through asp.net page's code?

I'm trying with "System.Environment.MachineName", but some hosting provider
doesn't allow the use of Environment.

Any idea?

Thank you.

Bye
 
System.Environment.MachineName

"System.Environment" is a namespace in the CLR.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
Hi Kevin.

Did you read my post ??!?
I don't think so...
System.Environment.MachineName
"System.Environment" is a namespace in the CLR.

"System.Environment" is not a namespace. It's a Class!

Anyway, as I said in my prevoius post, some hosting provider doesn't allow
the use of that class, for security reason.

So, I'm asking for another way to retrieve tha machine name (if exists).

Thanks.

Bye
 
Hi, Stefano.

Technically, you're right.

System.Environment is a Class within the System Namespace,
not a Namespace by itself, but coming down hard on Kevin,
who was only trying to point out to you that System.Environment
is available as a .Net resource, seems a bit unfair on your part.

It's easier to catch flies with honey than with vinegar.
After all, he was only trying to help you.

That said, what I'd like to know is *how* a hosting provider
can block requests to the System namespace, since that
namespace ( which includes System.Environment.MachineName )
is needed in order for the .NEt Framework to work,
since many internal processes use that namespace.

I've never heard of turning off access to
individual classes within a namespace, either.

Did you *try* to use System.Environment.MachineName ?
You might have a surprise coming to you...




Juan T. Llibre
ASP.NET MVP
===========
 
The problem is that when you access That property, the runtime issues a

EnvironmentPermission(Unrestricted).Demand();

But you can probably go through Server.ServerName since it makes a direct
call to the native Win32 dll
 
David Jessee said:
The problem is that when you access That property, the runtime issues a
EnvironmentPermission(Unrestricted).Demand();
But you can probably go through Server.ServerName since it makes a direct
call to the native Win32 dll

OK! This is an answer...! ;-)

I'll use Server.MachineName.

Thank you so much.

Bye

Stefano
 
Hi, Stefano.

Hi Juan

[...]
Kevin, who was only trying to point out to you that System.Environment
is available as a .Net resource, seems a bit unfair on your part.

OK, excuse me. It was not my intention...

But, if you read my first post, you can see that I already knew
System.Environment class.
It's easier to catch flies with honey than with vinegar.
After all, he was only trying to help you.

Yes, I know. And I appreciated this.
That said, what I'd like to know is *how* a hosting provider
can block requests to the System namespace, since that
namespace ( which includes System.Environment.MachineName )
is needed in order for the .NEt Framework to work,
since many internal processes use that namespace.

I'm going to explain this...
Environment.MachineName requires "EnvironmentPermission" as
"Unrestricted"...
I've never heard of turning off access to
individual classes within a namespace, either.

....so, hosting providers can turn off access to Environment.MachineName,
using restricted permissions for the Pool Identity user.

Thank you.

Bye!

Stefano
 
re:
hosting providers can turn off access to
Environment.MachineName, using restricted
permissions for the Pool Identity user.

Learn something every day...

Thanks!


Juan T. Llibre
ASP.NET MVP
===========
Stefano said:
Hi, Stefano.

Hi Juan

[...]
Kevin, who was only trying to point out to you that System.Environment
is available as a .Net resource, seems a bit unfair on your part.

OK, excuse me. It was not my intention...

But, if you read my first post, you can see that I already knew
System.Environment class.
It's easier to catch flies with honey than with vinegar.
After all, he was only trying to help you.

Yes, I know. And I appreciated this.
That said, what I'd like to know is *how* a hosting provider
can block requests to the System namespace, since that
namespace ( which includes System.Environment.MachineName )
is needed in order for the .NEt Framework to work,
since many internal processes use that namespace.

I'm going to explain this...
Environment.MachineName requires "EnvironmentPermission" as
"Unrestricted"...
I've never heard of turning off access to
individual classes within a namespace, either.

...so, hosting providers can turn off access to Environment.MachineName,
using restricted permissions for the Pool Identity user.

Thank you.

Bye!

Stefano
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top