Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx35 / System.ServiceModel.Web / System / ServiceModel / Dispatcher / JavascriptCallbackMessageInspector.cs / 1305376 / JavascriptCallbackMessageInspector.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- #pragma warning disable 1634, 1691 namespace System.ServiceModel.Dispatcher { using System.Net; using System.Linq; using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Web; using System.Web; using System.ServiceModel.Description; using System.Diagnostics; using System.ServiceModel.Diagnostics; class JavascriptCallbackMessageInspector : IDispatchMessageInspector { internal static readonly string applicationJavaScriptMediaType = "application/x-javascript"; public JavascriptCallbackMessageInspector(string callbackParameterName) { this.CallbackParameterName = callbackParameterName; if (DiagnosticUtility.ShouldTraceInformation) { TraceUtility.TraceEvent(TraceEventType.Information, TraceCode.JsonpCallbackNameSet, SR2.GetString(SR2.TraceCodeJsonpCallbackNameSet, callbackParameterName)); } } string CallbackParameterName { get; set; } public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext) { if (HttpContext.Current != null && HttpContext.Current.User != null && HttpContext.Current.User.Identity != null && HttpContext.Current.User.Identity.IsAuthenticated) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR2.CrossDomainJavascriptAuthNotSupported)); } return null; } public void BeforeSendReply(ref Message reply, object correlationState) { WebBodyFormatMessageProperty formatProperty; JavascriptCallbackResponseMessageProperty javascriptCallbackResponseMessageProperty = null; if (reply.Properties.TryGetValue(WebBodyFormatMessageProperty.Name, out formatProperty) && formatProperty != null && formatProperty.Format == WebContentFormat.Json) { if (!reply.Properties.TryGetValue (JavascriptCallbackResponseMessageProperty.Name, out javascriptCallbackResponseMessageProperty) || javascriptCallbackResponseMessageProperty == null) { javascriptCallbackResponseMessageProperty = WebHttpBehavior.TrySetupJavascriptCallback(this.CallbackParameterName); if (javascriptCallbackResponseMessageProperty != null) { reply.Properties.Add(JavascriptCallbackResponseMessageProperty.Name, javascriptCallbackResponseMessageProperty); } } if (javascriptCallbackResponseMessageProperty != null) { HttpResponseMessageProperty property; if (reply.Properties.TryGetValue (HttpResponseMessageProperty.Name, out property) && property != null) { property.Headers[HttpResponseHeader.ContentType] = applicationJavaScriptMediaType; if (javascriptCallbackResponseMessageProperty.StatusCode == null) { javascriptCallbackResponseMessageProperty.StatusCode = property.StatusCode; } property.StatusCode = HttpStatusCode.OK; if (property.SuppressEntityBody) { property.SuppressEntityBody = false; Message nullJsonMessage = WebOperationContext.Current.CreateJsonResponse
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EndpointIdentity.cs
- DiagnosticTrace.cs
- QueueProcessor.cs
- UserUseLicenseDictionaryLoader.cs
- MsdtcWrapper.cs
- MaskDescriptor.cs
- DrawingGroupDrawingContext.cs
- LogFlushAsyncResult.cs
- MessageTraceRecord.cs
- CommandArguments.cs
- XamlParser.cs
- OutputWindow.cs
- OperationAbortedException.cs
- SHA1.cs
- COM2EnumConverter.cs
- ClientScriptItem.cs
- Stylesheet.cs
- PasswordBox.cs
- ListViewInsertEventArgs.cs
- RedirectionProxy.cs
- SqlConnectionString.cs
- SectionInformation.cs
- ColorContextHelper.cs
- VisualStyleInformation.cs
- CommonObjectSecurity.cs
- NativeMethods.cs
- NameValuePair.cs
- MetadataArtifactLoaderFile.cs
- TaskHelper.cs
- EpmContentSerializer.cs
- ResourceLoader.cs
- DiscoveryExceptionDictionary.cs
- NGCSerializationManagerAsync.cs
- DesignerAttribute.cs
- RTLAwareMessageBox.cs
- WorkItem.cs
- DictionaryTraceRecord.cs
- SpecialFolderEnumConverter.cs
- GridViewCellAutomationPeer.cs
- InvalidDataContractException.cs
- XamlFilter.cs
- ListSortDescriptionCollection.cs
- COAUTHINFO.cs
- WpfXamlMember.cs
- XmlNullResolver.cs
- HtmlTableRow.cs
- UIElementIsland.cs
- BitmapPalettes.cs
- BaseDataList.cs
- Connector.cs
- WsdlInspector.cs
- HtmlPhoneCallAdapter.cs
- JsonServiceDocumentSerializer.cs
- CodePageEncoding.cs
- RootProfilePropertySettingsCollection.cs
- HealthMonitoringSectionHelper.cs
- SqlDataSourceFilteringEventArgs.cs
- PenThreadPool.cs
- SqlProcedureAttribute.cs
- IBuiltInEvidence.cs
- Accessible.cs
- Identifier.cs
- UTF8Encoding.cs
- OutputCacheSection.cs
- DbException.cs
- ISSmlParser.cs
- ToolStripItemClickedEventArgs.cs
- SafeNativeMethodsOther.cs
- ValueSerializer.cs
- RegistryConfigurationProvider.cs
- WindowsListViewGroup.cs
- XmlSigningNodeWriter.cs
- LoginCancelEventArgs.cs
- NamedObject.cs
- SAPIEngineTypes.cs
- MaterializeFromAtom.cs
- COM2AboutBoxPropertyDescriptor.cs
- XmlSchemaAttributeGroupRef.cs
- TextSearch.cs
- ConstrainedGroup.cs
- DesignerForm.cs
- Misc.cs
- UnsafePeerToPeerMethods.cs
- InternalBufferOverflowException.cs
- TypefaceMap.cs
- XmlHierarchicalEnumerable.cs
- XamlGridLengthSerializer.cs
- SendingRequestEventArgs.cs
- COM2ExtendedUITypeEditor.cs
- FontFamilyValueSerializer.cs
- ClosureBinding.cs
- DynamicResourceExtensionConverter.cs
- AuthenticationService.cs
- ListBox.cs
- SafeFileMappingHandle.cs
- AppModelKnownContentFactory.cs
- SplineKeyFrames.cs
- WebPart.cs
- FileDialogCustomPlace.cs
- MulticastDelegate.cs