IIS7中的unable to generate a temporary class错误解决办法

本文解决了一个在IIS7上运行的ASP页面出现的ServiceUnavailable错误,该错误与调用WebService/WCFService时ASP.NET在C:WindowsTEMP文件夹中的操作有关。通过为IIS_IUSRS账户添加读写权限,问题得以解决。

在访问IIS7的网站时,可能会遇到Service Unavailable的错误,错误的原因当然可能会有很多种,因此需要使用Just-In-Time Debugger来go into到实际的内部错误。

错误信息
System.ServiceModel.CommunicationException was unhandled
  Message=There was an error in serializing body of message SearchRequest1: 'Unable to generate a temporary class (result=1).
error CS2001: Source file 'C:\Windows\TEMP\s0phakvt.0.cs' could not be found
error CS2008: No inputs specified
'.  Please see InnerException for more details.
  Source=mscorlib
  StackTrace:
    Server stack trace:
       at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter writer, MessageVersion version, String action, MessageDescription messageDescription, Object returnValue, Object[] parameters, Boolean isRequest)
       at System.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessage.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)
       at System.ServiceModel.Channels.BodyWriter.WriteBodyContents(XmlDictionaryWriter writer)
       at System.ServiceModel.Channels.Message.OnWriteMessage(XmlDictionaryWriter writer)
       at System.ServiceModel.Channels.BufferedMessageWriter.WriteMessage(Message message, BufferManager bufferManager, Int32 initialOffset, Int32 maxSizeQuota)
       at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.WriteMessage(Message message, Int32 maxMessageSize, BufferManager bufferManager, Int32 messageOffset)
       at System.ServiceModel.Channels.HttpOutput.SerializeBufferedMessage(Message message)
       at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
       at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

解决办法:
右键点击C:\Windows\TEMP 目录,选择 properties->security ,添加 MachineName\IIS_IUSRS 账户(将MachineName替换成实际的服务器名称),给予它Read、Write、List等权限。再重新访问这个ASP页面,问题应该能够得到解决。

原因分析:
应该是在你的ASP页面中,调用了别的Web Service/WCF Service,ASP.NET Web Service有时候会在处理WebMethods时使用到C:\Windows\TEMP文件夹,因此需要给IIS的相关账户赋予相应的权限。

转载于:https://www.cnblogs.com/kentico/archive/2012/10/24/2736814.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值