2008年9月18日 星期四

"build error" allowDefinition='MachineToApplication

http://msdn.microsoft.com/en-us/library/aa479312.aspx

As mentioned before, Visual Studio 2005 normally considers all files in a folder or sub-folder to be part of the Web project. By default, the conversion wizard will create a backup of your Web project in a safe location, but it is possible for the user to overwrite the default. If you put the backup folder in the Web application's folder tree, you will get this somewhat cryptic build error:

Error 1 - It is an error to use a section registered as 
allowDefinition='MachineToApplication' beyond application level

How to fix

Make sure your backup location is not in the Web application's root folder or sub-folder!

2008年9月5日 星期五

WCF 使用ASP.NET 的Session

http://silverlight.net/forums/p/23080/81722.aspx

Hello, session is a server side concept.
Silverlight runs on the client, so it has no
knowledge of the session. But you can pass some
variable from the Silverlight application to the
server via a web service. Then in the web
service, you store it as a session variable.
Later when you call another web service, you can
check the session variable and return it to the
client.

While WCF also has built-in session
support, BasicHttpBinding doesn't support that.
So you need to use ASP.NET session instead. To
enable ASP.NET session on WCF, you need to turn
on ASP.NET Compatibility. Do the following:



  • In web.config, under system.serviceModel
    tag, add this line:


<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>



  • On your service class (not interface), add this attribute:


[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]



  • Now you can use ASP.NET session with the
    following syntax:


HttpContext.Current.Session["YourName"] = something;


object something = HttpContext.Current.Session["YourName"];