IIS7 + WCF + Silverlight problems - wcf

I've been building a silverlight application and a WCF service for a while now and recently tried to host them in IIS7.
I installed IIS7 on Windows Server 2008 R2 and added these two application to my default website. I am having a number of problems so im hoping one of you can help out...
1) The silverlight and WCF service applications do not work with pass-through authentication. I need to "connect as" the administrator server account when setting up the application. I read online that you should only need to use the "connect as" field when you are connecting to another computer. If i dont supply the admin credentials i get this error. Do i have to set up permissions somewhere else?
HTTP Error 500.19 - Internal Server Error The requested page cannot be
accessed because the related configuration data for the page is
invalid. Detailed Error Information Module IIS Web Core Notification
BeginRequest Handler Not yet determined Error Code 0x80070005 Config
Error Cannot read configuration file due to insufficient permissions
Config File \?\C:\Users\Administrator\Documents\My Dropbox\Research
Masters\Project\WCFService\Website\web.config Requested URL
http:://localhost:80/WCFService/Service.svc Physical Path
C:\Users\Administrator\Documents\My Dropbox\Research
Masters\Project\WCFService\Website\Service.svc Logon Method Not yet
determined Logon User Not yet determined Config Source -1:
0: Links and More Information This error occurs when there is a
problem reading the configuration file for the Web server or Web
application. In some cases, the event logs may contain more
information about what caused this error.
2) Visual studio generated 2 webpages to run my silverlight application (.html and .aspx). When I am running the silverlight application (connected as admin) I can navigate to the .html page, no problem. When I try to open the .aspx file i get the following error
Server Error in '/Platform' Application.
Access is denied.
Description: An error occurred while accessing the resources required
to serve this request. You might not have permission to view the
requested resources.
Error message 401.3: You do not have permission to view this directory
or page using the credentials you supplied (access denied due to
Access Control Lists). Ask the Web server's administrator to give you
access to 'C:\Users\Administrator\Documents\My Dropbox\Research
Masters\Project\Platform\Website\PlatformTestPage.aspx'.
Version Information: Microsoft .NET Framework Version:4.0.30128;
ASP.NET Version:4.0.30128.1
3) The WCF service runs fine (again, connected as admin) until i restart the server. When i try to run the WCF service after a reboot, the mysql assembly seems to be missing from the solution. If i just rebuilt the solution and run the service again... it works (until next restart). Whats causing this error?
Solution here - http://tinypic.com/view.php?pic=5yasqx&s=5
Server Error in '/WCFService' Application.
Could not load file or assembly 'MySql.Data, Version=6.2.2.0,
Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its
dependencies. Access is denied.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadException: Could not load file or
assembly 'MySql.Data, Version=6.2.2.0, Culture=neutral,
PublicKeyToken=c5687fc88969c44d' or one of its dependencies. Access is
denied.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to
determine why the assembly 'MySql.Data, Version=6.2.2.0,
Culture=neutral, PublicKeyToken=c5687fc88969c44d' could not be loaded.
WRN: Assembly binding logging is turned OFF. To enable assembly bind
failure logging, set the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There
is some performance penalty associated with assembly bind failure
logging. To turn this feature off, remove the registry value
[HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace:
[FileLoadException: Could not load file or assembly 'MySql.Data,
Version=6.2.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or
one of its dependencies. Access is denied.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String
codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint,
StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean
forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName
assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark,
Boolean forIntrospection, Boolean suppressSecurityChecks) +567
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,
Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean
forIntrospection) +192 System.Reflection.Assembly.Load(String
assemblyString) +35
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String
constructorString, Uri[] baseAddresses) +243
System.ServiceModel.HostingManager.CreateService(String
normalizedVirtualPath) +1423
System.ServiceModel.HostingManager.ActivateService(String
normalizedVirtualPath) +50
System.ServiceModel.HostingManager.EnsureServiceAvailable(String
normalizedVirtualPath) +1132
[ServiceActivationException: The service '/WCFService/Service.svc'
cannot be activated due to an exception during compilation. The
exception message is: Could not load file or assembly 'MySql.Data,
Version=6.2.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or
one of its dependencies. Access is denied..]
System.Runtime.AsyncResult.End(IAsyncResult result) +889824
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult
result) +179150
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult
ar) +107
Version Information: Microsoft .NET Framework Version:4.0.30128;
ASP.NET Version:4.0.30128.1
Thats about it, hope someone reads this message, I wasted most of the weekend trying to fix these problems on my own... thanks

My suggestions:
1) Check your web application folder's permissions. You should edit the permissions on your web application folder so that the IIS user can read from the folder.
So you should open the folder properties dialog for the folder in the windows explorer and check if the application pool user has at least read permissions. If you didn't provide another user for the application pool, then the default user should be IIS_IUSRS.
2) Check if the asp.net is enabled in your system by running:
If you have .Net 4 installed in your system:
"%WINDIR%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe" –i
Otherwise:
"%WINDIR%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe" –i
The above command will register/repair the your .Net installation with the IIS.
3) Is your mysql dll locate in the bin folder? I would check if you also have permissions to read this folder. If the dll is not in the same folder as your application dll, check if the dll is installed in the GAC.
Regards,

1)Give permissions to the folder for the IIS_IUSRS group.
Also see if the application pool for the application in IIS manager->"Application Pools" has the Identity set as "LocalSystem". For me it was "NetworkService", setting it to "LocalSystem" solved it.

You must not be able to host silverlight applications with IIS7.
Try hosting your silverlight app on an apache server with a php / html script.
Hope that helps mate
Please rate my answer
Anzwerx

Related

Default VS2012 ASP.NET Web Site Template on Medium Trust Host

I have a default ASP.NET Web Site template project that I created with VS2012. I'm trying to publish it to 1and1.com where only Medium trust is allowed. Apparently, this template expects Full trust, but I can't figure out what I need to do.
The error I'm getting is...
[SecurityException: Request for the permission of type 'System.Security.Permissions.TypeDescriptorPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessSecurityEngine.Check(PermissionSet permSet, StackCrawlMark& stackMark) +31
System.Security.PermissionSet.Demand() +68
System.ComponentModel.TypeDescriptor.AddProviderTransparent(TypeDescriptionProvider provider, Type type) +153
System.Web.DynamicData.MetaModel.CreateSimpleModel(Type entityType) +77
System.Web.DynamicData.MetaTable.CreateTable(Type entityType) +9
System.Web.UI.DataControlExtensions.GetTableFromCache(Type entityType) +64
System.Web.UI.DataControlExtensions.EnableDynamicData(INamingContainer control, Type entityType) +14
From the stacktrace I infer you're using DynamicData in your website, and you said you're using the Web Site template in Visual Studio.
There are a couple of issues with that, but you can try a couple of things:
1: Don't use the Web Site template, but the Web Application template
or
2: Precompile the Website before deploying
or
3: Move the edmx file from the App_Code directory to a seperate library, compile it and add the resulting .dll to the websites bin folder.
Here and here you can find more info about this problem.

Exposing wcf service in BizTalk 2010

I have ran into this issue the past few weeks ago and I still can not figure out why.
I have a BizTalk orchestration that receives a BizTalk message, processes it and eventually writes it to a file. For simplicity sake, let say, our goal is to take the message (which is actually a survey) and save it to a folder as is. I have created a public receive port to catch the msg and a send port to write the result out to disk.
I have successfully deployed the project and have successfully published it to IIS. I was able to see the WCF service in IIS and have set it to use Framework 4.0. I have set up all the relevant receive and send ports and have started the application successfully from BizTalk management console. (The receive location was automatically created when I published the wcf service, the send location is a type FILE located in a folder in the computer)
From DefaultSite in IIS, I could see my WCF. However, when I tried http://localhost/TestSurvey/TestSurvey_Orchestration_1_getSurveyPort.svc,
I got the following error:
Server Error in '/TestSurvey' Application.
--------------------------------------------------------------------------------
Login failed for user 'Domain\ComputerName$'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'ACAD1\DENBIZDEV$'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SqlException (0x80131904): Login failed for user 'Domain\ComputeName$'.]
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
Microsoft.BizTalk.TransportProxy.Interop.IBTTransportProxy.RegisterIsolatedReceiver(String url, IBTTransportConfig callback) +0
Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfIsolatedReceiver`2.RegisterIsolatedReceiver(Uri uri) +1028
Microsoft.BizTalk.Adapter.Wcf.Runtime.WebServiceHostFactory`3.CreateServiceHost(String constructorString, Uri[] baseAddresses) +363
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1413
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +50
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1172
[ServiceActivationException: The service '/TestSurvey/TestSurvey_Orchestration_1_getSurveyPort.svc' cannot be activated due to an exception during compilation. The exception message is: Exception has been thrown by the target of an invocation..]
System.Runtime.AsyncResult.End(IAsyncResult result) +901424
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178638
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +107
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
My question is: what is it that BizTalk was trying to login? Domain\ComputerName$ is definitely not a user. I have not tried to access any database from the orchestration. I believe my IIS was set up correctly as I have created a quick and dirty wcf service test from VS2010 and published it to my IIS, then have successfully created a simple client to consume the wcf service test. I did not encounter the same issue when I created the wcf service test directly.
Any help or hint is highly appreciated!
EDIT
I managed to fix this: it was not the web config as it was created by BizTalk. I had to create a special app pool and tied my application to using it. In the app pool I have to use the custom credential that BizTalk is using. Using the built in credentials caused the issue I experienced. My rookie error! Once BizTalk login credential was used, everything went smoothly.
The database which is throwing the SQL exception is one of the BizTalk databases, probably the management or SSO DB.
The error is almost certainly being caused by the setup of IIS, whether the app pool identity or the web site security settings.
What is hapenning is that when you call the service for the first time IIS is compiling your service, and to do this it obviously needs access to one of the BizTalk databases, but this call is not authenticated for some reason.
This could be because the app pool user must be a member of the BizTalk Isolated Host Users group (which may be called something different depending on how BizTalk was set up.

WCF service running under custom identity resets connection for WSDL's XSD includes

I have requirements to configure IIS 6 to host a WCF service targeting .NET Framework 4.0 using a custom identity for the worker process. The identity is a highly restricted domain account that is used to identify and manage the permissions for an entire ecosystem of services that interact in the same business process.
I have run aspnet_regiis.exe with the -ga flag to grant this identity permissions to the relevant ASP.NET locations on the server environment and add it to the IIS_WPG group. For the most part, things seem to work relatively well... except for the auto-generated WSDL specification's includes. Accessing the top-level WSDL spec works fine (i.e. path.to/MyService.svc?wsdl), but IIS 6 is resetting the connection before returning the response for the WSDL's includes (i.e. path.to/MyService.svc?xsd=xsd0, etc). This happens both when accessed via loopback on the server and through the public IP. It does not happen when reconfiguring the app pool to run under the default Network Service account.
I haven't found any documentation for this particular problem, but it's not the first time I've had difficulty with certain bits of the .NET Framework not quite working correctly when the IIS 6 worker process is running under a custom domain identity. I haven't configured any special privileges in the Local Security Policy for this account, other than the pre-configured permission for members of IIS_WPG to log on as a batch job. What might I be missing to get the worker functioning correctly?
EDIT:
The Event Viewer contains no errors and IIS logs show the server responding with 200 OK to the request, but the full status value is 200 0 64, indicating a Win32 status code of 64.
The dump I receive on that error from net helpmsg 64 is as follows:
The specified network name is no longer available.
Responses from various entities are below:
Chrome: Error 101 (net::ERR_CONNECTION_RESET): The connection was reset
Firefox: The connection to the server was reset while the page was loading
Eclipse/Java: java.net.SocketException: Connection reset
EDIT:
Service logging (provided by BNL) produced the following exception dump:
System.InvalidOperationException: Unable to generate a temporary class
(result=1). error CS2001: Source file 'C:\WINDOWS\TEMP\vxmgwmnl.0.cs'
could not be found. error CS2008: No inputs specified.
at System.Xml.Serialization.Compiler.Compile(Assembly parent, String
ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
at
System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[]
xmlMappings, Type[] types, String defaultNamespace, Evidence evidence,
XmlSerializerCompilerParameters parameters, Assembly assembly,
Hashtable assemblies) at
System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings,
Type[] types, String defaultNamespace, String location, Evidence
evidence) at System.Xml.Serialization.XmlSerializer..ctor(Type type,
String defaultNamespace) at
System.Xml.Schema.XmlSchema.Write(XmlWriter writer,
XmlNamespaceManager namespaceManager) at
System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.XmlSchemaMessage.OnWriteBodyContents(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.HttpRequestContext.OnReply(Message
message, TimeSpan timeout) at
System.ServiceModel.Channels.RequestContextBase.Reply(Message message,
TimeSpan timeout) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.Reply(MessageRpc&
rpc)
Using the guidelines on the Microsoft KB article Error message when ASP.NET 2.0 is configured to run with a user account: "Unable to generate a temporary class", I located the C:\Windows\Temp directory and inspected its folder properties by right-clicking and choosing Properties. I then navigated to the Security tab and clicked Advanced, then Add. I entered the name of the IIS_WPG group on the local computer and allowed it only the special permission List Folder / Read Data. This has now resolved the issue.

WCF service hosted in IIS throws 'Failed to access IIS metabase' error

Deployed a WCF service in IIS 6.0 gave NETWORK_sERVICE user read/write privileges.
When tries to brows to .SVC file i get below error
Failed to access IIS metabase.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.Hosting.HostingEnvironmentException: Failed to access IIS metabase.
The process account used to run ASP.NET must have read access to the IIS metabase (e.g. IIS://servername/W3SVC). For information on modifying metabase permissions, please see http://support.microsoft.com/?kbid=267904.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HostingEnvironmentException: Failed to access IIS metabase.]
System.Web.Configuration.MetabaseServerConfig.MapPathCaching(String siteID, VirtualPath path) +637
System.Web.Configuration.MetabaseServerConfig.System.Web.Configuration.IConfigMapPath2.MapPath(String siteID, VirtualPath vpath) +9
System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath, Boolean permitNull) +174
System.Web.Hosting.HostingEnvironment.MapPathInternal(VirtualPath virtualPath, Boolean permitNull) +51
System.Web.CachedPathData.GetConfigPathData(String configPath) +341
System.Web.CachedPathData.GetConfigPathData(String configPath) +234
System.Web.CachedPathData.GetApplicationPathData() +38
System.Web.CachedPathData.GetVirtualPathData(VirtualPath virtualPath, Boolean permitPathsOutsideApp) +8806383
System.Web.Configuration.RuntimeConfig.GetLKGRuntimeConfig(VirtualPath path) +117
Any thoughts?
Was told that we get 'Failed to access IIS metabase' error if we install IIS after intalling .NET Framework, and remedy is to re-install ASP.NET.
To resolve this error I have followed below steps
1. Stopped IIS
2. Ran below command in command prompt to re-install aspnet.
%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i
Result:
Start installing ASP.NET (2.0.50727).
..................................................................
Finished installing ASP.NET (2.0.50727).
3. Re-started IIS and WCF service is responding without any issues.

NHibernate WCF Rest IIS7 Fails with Security Exception

Here is the error:
System.TypeInitializationException: The type initializer for 'NHibernate.Cfg.Environment' threw an exception.
---> System.Security.SecurityException: Request for ConfigurationPermission failed while attempting to access configuration section 'hibernate-configuration'. To allow all callers to access the data for this section, set section attribute 'requirePermission' equal 'false' in the configuration file where this section is declared.
---> System.Security.SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Configuration.BaseConfigurationRecord.CheckPermissionAllowed(String configKey, Boolean requirePermission, Boolean isTrustedWithoutAptca)
We have the trust level set to Full. Note also that we also have a web site that runs the SAME Nhibernate code and has NO issues. Only the WCF REst Web Service Application has this error?
Any Thoughts as to WHY this is a problem?
http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/107/threadid/344545/scope/posts/Default.aspx
change the Identity of the app pool from "ApplicationPoolIdentity" to "NetworkService" and give "NetworkService" account "modify" permissons on the file system folder.