user96271
user96271

Reputation: 5

Security error in ASP NET shared account

These lines cause a security exception in a godaddy account. Any suggestions how to rewrite to get this to work?

File.Delete(PropsFileName);     // Clean up

TextWriter tw = new StreamWriter(PropsFileName);    // Create & open the file
tw.WriteLine(DateTime.Now);     // Write the date for reference
tw.WriteLine(TokenLine);        // Write the BinarySecurityToken
tw.WriteLine(ConvIdLine);       // Write the ConversationId
tw.WriteLine(ipccLine);     // Write the IPCC
tw.Close();

Thanks!

The information is being written to session.properties variable in the temp directory.

Upvotes: 0

Views: 119

Answers (2)

Jon Erickson
Jon Erickson

Reputation: 114876

GoDaddy is set up to run under Medium trust, to simulate this on localhost add the following to your web.config:

<system.web>
    <trust level="Medium" />
</system.web>

Something you can try to fix the issues is to add the following to your AssemblyInfo.cs under Project > Properties in solution explorer

[assembly: AllowPartiallyTrustedCallers]

Also here is an article that may or may not help you out and/or give you insight regarding a similar situation with NHibernate: NHibernate in a Medium Trust Environment

Upvotes: 1

Mehrdad Afshari
Mehrdad Afshari

Reputation: 421988

You should give NTFS permissions to the user running your ASP.NET app. Your hosting control panel probably supports assigning NTFS permissions to the folder.

Upvotes: 0

Related Questions