Let me preface this (Because I know I'll get this eventually in the responses)
Yes I know about WCF, but we are not using that or plan to right now (boss won't budge)
Ok, so my questions are the following. First I want to move some of our .asmx into a separate project. Right now it's in several scattered folders in our WAP project. Ok so if I create a new project:
1) What type should it be?
2) What deployment issues do I now have to face? Someone told me that if we move it to a separate project, we have to deploy it separately, I assume that means IIS, and yes, copying up that project to another place on the server
3) I was told that if we move it out of the WAP project we can no longer have that service run under our domain (something.com). But then someone told me you can setup a single web service to be a "pass-through" and have the actual .asmx files wherever you want? I don't get that.
The main concern is moving it. How to expose the services in that web project as we'll have multiple. How to deploy (both the files and IIS) it and then how to make sure it's still available under our same domain in production.
The asmx file is simply a pointer to the C# code file. You can include the asmx files anywhere in your web project.
You can create a Web Service project in Visual Studio IDE, or simply create a Class Library and add the necessary references.
A web service project uses the following DLLs:
System.EnterpriseServices
System.Web
System.Web.Extensions
System.Web.Mobile
System.Web.Services
And the following web.config reference:
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpHandlers>
Agreed, create a new Web Service Project.
There's no issue having your webservice be deployed alongside your existing site in IIS.
Create your existing site url www.something.com then within IIS add a virtual directory or application to myservice so that you get www.something.com/myservice/awesome.asmx.
You could also create yourself an alternate host header to direct webservices.something.com to your webservices.
Related
I work on a large Visual Studio Solution (Sitecore Helix), with separate "feature" Projects. Some Projects have a Views > Web.config file and others do not.
During our build process, all Views end up one location/project and in that final destination the Views folder does have it's production Web.config file.
However, without a Views > Web.config file at individual the Project, there is no IntelliSense for the (dynamic) #model. Strongly typed Objects (#Html.Raw) have autocomplete/IntelliSense. As a front-end person, I really rely on the IntelliSense.
Is there a better/more appropriate way of adding these references other than to adding an individual Web.config (example below) to each Project, especially since I just need this for debug/development.
Example Web.config, please note this is not my entire Web.config file, but specifically the lines I have narrowed down to make the IntelliSense work in this case.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="Sitecore.Mvc" />
<add namespace="Sitecore.Mvc.Presentation" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="GCC.Feature.WebAdmin" />
</namespaces>
</pages>
</system.web.webPages.razor>
</configuration>
IntelliSense working on something other than #model
IntelliSense not working on #model no web config
IntelliSense working with Web.config
I am writing/ have written a file upload portal for my company that requires the ability to upload a ton of different file types of various sizes and quantities. I used the AJaxControlToolkit AjaxFileUpload control.
The upload works well except when we upload what seems like IIS reserved file types. We can upload images, entire non-zipped folders, office docs etc.
When I try to upload the reserved file type the Firefox developer tools returns a server error, 'File Extension Not Allowed' error. This happens with .exe files and the one we need .stl files(in our case these are for 3d printing).
We have played with config files, Handler Mappings, HTTP response headers, MIME type configurations, and request filtering on the IIS manager at the app level, site level and server level and none seem to work.
The last bit of info is that zipping the file seems to get it through but we'd like to avoid asking the customer to do that.
IIS 8.5,
C# .Net,
Windows Server 2012 R2
I can post code if you need it but I am pretty sure it is a server configuration we need to change
Thanks for your help.
Walt
Edit:
Below is my Config with the Fix included. this was an issue with white listed file types by the control and not the server. Thank you
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="ajaxControlToolkit" type="AjaxControlToolkit.AjaxControlToolkitConfigSection, AjaxControlToolkit" requirePermission="false"/>
</configSections>
<appSettings/>
<ajaxControlToolkit additionalUploadFileExtensions="bmp,stl"></ajaxControlToolkit>
<system.webServer>
<handlers>
<add name="aa2" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>
</handlers>
</system.webServer>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Services.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Services.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
<pages>
<controls>
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit"/>
</controls>
</pages>
</system.web>
</configuration>
You need to add the additionalUploadFileExtensions attribute to ajaxControlToolkit section in Web.config:
<ajaxControlToolkit additionalUploadFileExtensions="exe,stl" />
Please refer to this article: https://github.com/DevExpress/AjaxControlToolkit/wiki/AjaxFileUpload-setup
For an example of where to ajaxcontroltoolkit entry in the web.config file, please refer to Sample web.config Ajax configuration
Sample below:
<configuration>
<configSections>
<section name="ajaxControlToolkit" type="AjaxControlToolkit.AjaxControlToolkitConfigSection, AjaxControlToolkit" requirePermission="false"/>
</configSections>
<ajaxControlToolkit
useStaticResources="true"
renderStyleLinks="false"
htmlSanitizer="AjaxControlToolkit.HtmlEditor.Sanitizer.DefaultHtmlSanitizer, AjaxControlToolkit.HtmlEditor.Sanitizer"
tempFolder="~/Temp"/>
<location path="Temp">
<system.webServer>
<handlers>
<clear/>
</handlers>
<modules>
<clear/>
</modules>
</system.webServer>
</location>
<system.web>
I have a web application (asp.net webforms) that uses telerik controls, such as telerik:ReportViewer and telerik:RadTimePicker.
The interesting part is, the telerik library extensively uses the same dll (e.g. System.Web.Extensions), causing IIS Manager to issue "Duplicate Reference" error. Trying to simply delete the duplicate references causes some parts of the website to stop working.
How can I make same references to a single DLL within Web.config, without having to add duplicates??
Look why:
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
IIS reports duplicate references for each section element above. Deleting them causes the time picker to not show when clicked.
The same references goes in other places:
<compilation debug="true">
<assemblies>
...
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
...
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
...
</compilation>
And also:
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>
<modules>
<remove name="ScriptModule"/>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>
When running using Visual Studio (Debugging), everything fine. But once deployed to IIS, IIS reports errors of duplicates!!
It seems your website has been updated from old .NET versions and has become a mess of sections that newer .NET versions do not need. VS does not really rung on IIS by default so it probably does not read the entire web.config, hence things working on dev.
So, what you can try is:
start a new blank WebForms application targetting .NET 4 or .NET 4.5 , depending on what you target and copy its web.config. What you need to make sure is that you can run MS AJAX properly, so a simple asp:UpdatePanel on the page should let you have a working page first. This includes making sure all webresource requests pass.
see what you need to add for Telerik's controls here: http://www.telerik.com/help/aspnet-ajax/web-config-settings-overview.html#mandatory-additions. It is just a few handlers, those sections that error out are used by the core MS AJAX functionality.
try adding bindingRedirect element for the old Web.Extensions assembly to the new one.
AT.Anchor = System.Guid.Parse(DataBinder.Eval(e.Item.DataItem, "Anchor").ToString());
This throws:
'System.Guid' does not contain a definition for 'Parse'
When I try and build it. But it runs fine, any idea how I can handle this better?
Edit
Here is a section of my web.config
<compilation defaultLanguage="c#" debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add assembly="System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
<add assembly="MySql.Data.Entity, Version=6.3.6.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
<add assembly="MySql.Web, Version=6.3.6.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/></assemblies>
</compilation>
Guid.TryParse is part of .NET 4. Make sure you're both building and running against .NET 4, and it should be fine.
One of the things with IIS app pools is that the first web application that starts in an app pool determines the CLR version used by that app pool.
If the first app started was built for, say, .Net v1.1, then every app started after that will run against the v1.1 runtime. If your app, which gets started next, was built for, say, the 4.0 runtime, you're unlikely to find happiness. Some might consider this to be a feature. Or not.
"Start", in this case, means "receives an HTTP request". This means that the runtime version you get is essentially random: it depends on what the clients do, and in what order, after your bounce the app pool or bounce IIS.
You need to be careful to put your web apps in appropriate app pools. Either bundle each web app in its own app pool, or set up an app pool per CLR version and be careful to put your web apps in the correct app pool.
We use the caching and logging application blocks from entlib 4.1. We want to keep the configuration of those two in seperate files. How can we achieve this?
It looks like entlib is always using the selectedSource as it configuration.
I tried the following:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9057346a2b2dcfc8" />
</configSections>
<enterpriseLibrary.ConfigurationSource selectedSource="messagesCache">
<sources>
<add name="messagesCache" filePath="Configuration\\messagesCache.config" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9057346a2b2dcfc8" />
<add name="logging" filePath="Configuration\\logging.config" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9057346a2b2dcfc8" />
</sources>
</enterpriseLibrary.ConfigurationSource>
</configuration>
But this doesn't work because the application blocks always use the selectedSource attribute value.
As noted in External configuration files in Enterprise Library for .NET Framework 2.0:
[...] while you can configure as many
Configuration Sources as you want
using the tool, only one is ‘selected’
to be the one which Enterprise Library
will automatically use [...]
What I have done is use the configSource attribute:
<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<section name="validationConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Validation.Configuration.ValidationSettings, Microsoft.Practices.EnterpriseLibrary.Validation, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<loggingConfiguration configSource="logging.config"/>
<exceptionHandlingConfiguration configSource="exceptionHandling.config"/>
<dataConfiguration configSource="dataAccess.config"/>
<validationConfiguration configSource="validation.config"/>
</configuration>
It works great, but the downside is that if you are editing your application/web config file using the configuration tool and save your configuration it will be saved inside the application/web config file.