Code:
/ DotNET / DotNET / 8.0 / untmp / Orcas / RTM / ndp / fx / src / xsp / System / Web / Extensions / Script / Services / WebServiceClientProxyGenerator.cs / 1 / WebServiceClientProxyGenerator.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Script.Services { using System; using System.IO; using System.Reflection; using System.Web; internal class WebServiceClientProxyGenerator : ClientProxyGenerator { private string _path; // Called by ScriptManager to generate the proxy inline internal static string GetInlineClientProxyScript(string path, HttpContext context, bool debug) { WebServiceData webServiceData = WebServiceData.GetWebServiceData(context, path, true, false, true); WebServiceClientProxyGenerator proxyGenerator = new WebServiceClientProxyGenerator(path, debug); return proxyGenerator.GetClientProxyScript(webServiceData); } private static DateTime GetAssemblyModifiedTime(Assembly assembly) { AssemblyName assemblyName = assembly.GetName(); DateTime writeTime = File.GetLastWriteTime(new Uri(assemblyName.CodeBase).LocalPath); // DevDiv 52056: include writeTime.Second in the date, otherwise if you modify it within the same minute it we'd still respond with http status 304 not modified return new DateTime(writeTime.Year, writeTime.Month, writeTime.Day, writeTime.Hour, writeTime.Minute, writeTime.Second); } // This is called thru the RestClientProxyHandler internal static string GetClientProxyScript(HttpContext context) { WebServiceData webServiceData = WebServiceData.GetWebServiceData(context, context.Request.FilePath); DateTime lastModifiedDate = GetAssemblyModifiedTime(webServiceData.TypeData.Type.Assembly); // If the browser sent this header, we can check if we need to resend string modifiedSince = context.Request.Headers["If-Modified-Since"]; if (modifiedSince != null) { DateTime header; if (DateTime.TryParse(modifiedSince, out header)) { // We are done if the assembly hasn't been modified if (header >= lastModifiedDate) { context.Response.StatusCode = 304; return null; } } } bool debug = RestHandlerFactory.IsClientProxyDebugRequest(context.Request.PathInfo); // Only cache for release proxy script (/js) if (!debug) { // Only cache if we get a reasonable last modified date if (lastModifiedDate.ToUniversalTime() < DateTime.UtcNow) { // Cache the resource so we don't keep processing the same requests HttpCachePolicy cachePolicy = context.Response.Cache; cachePolicy.SetCacheability(HttpCacheability.Public); cachePolicy.SetLastModified(lastModifiedDate); // expires is necessary so that the browser at least does an If-Modified-Since request on every request. // without that, the browser wouldn't request a new proxy until the user hits refresh. // Use one year ago to reasonably ensure "past" interpretation cachePolicy.SetExpires(lastModifiedDate.AddYears(-1)); } } WebServiceClientProxyGenerator proxyGenerator = new WebServiceClientProxyGenerator(context.Request.FilePath, debug); return proxyGenerator.GetClientProxyScript(webServiceData); } internal WebServiceClientProxyGenerator(string path, bool debug) { // internal because ExtensionsTest needs this path to bypass httpcontext _path = path; _debugMode = debug; } protected override string GetProxyPath() { return _path; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataBindingCollection.cs
- Walker.cs
- WebBrowserEvent.cs
- DataGridViewAccessibleObject.cs
- ProcessRequestArgs.cs
- ExitEventArgs.cs
- GenericXmlSecurityToken.cs
- ReferenceEqualityComparer.cs
- COMException.cs
- SecureStringHasher.cs
- TableLayoutSettings.cs
- RuleSettingsCollection.cs
- ErrorTableItemStyle.cs
- ConcurrentBag.cs
- SegmentInfo.cs
- CommaDelimitedStringAttributeCollectionConverter.cs
- SiteMembershipCondition.cs
- RtfToXamlReader.cs
- PersonalizablePropertyEntry.cs
- PasswordTextContainer.cs
- UshortList2.cs
- MaterialGroup.cs
- Annotation.cs
- WindowsFormsHelpers.cs
- DataGridCellsPresenter.cs
- TableLayoutCellPaintEventArgs.cs
- TreeView.cs
- Tuple.cs
- CustomErrorCollection.cs
- CommandArguments.cs
- TreeView.cs
- LinqDataSource.cs
- SaveFileDialog.cs
- ProgressBarRenderer.cs
- ArrangedElementCollection.cs
- UInt16Storage.cs
- _NestedMultipleAsyncResult.cs
- ArgumentFixer.cs
- DrawingBrush.cs
- WindowsStartMenu.cs
- SecurityPermission.cs
- ConfigXmlAttribute.cs
- TextTreeObjectNode.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- WebPartTransformer.cs
- ElementHost.cs
- ComponentResourceManager.cs
- StrokeNode.cs
- EntityDataSourceContainerNameItem.cs
- Trigger.cs
- IApplicationTrustManager.cs
- SafeProcessHandle.cs
- ListItemParagraph.cs
- SubMenuStyle.cs
- ColorConvertedBitmapExtension.cs
- HashSet.cs
- Decimal.cs
- StructuredTypeEmitter.cs
- BigInt.cs
- CryptoApi.cs
- DynamicQueryableWrapper.cs
- ApplicationHost.cs
- OdbcConnectionPoolProviderInfo.cs
- BitmapEffectGroup.cs
- TreeNodeStyleCollection.cs
- XslTransformFileEditor.cs
- FormsAuthenticationUserCollection.cs
- Native.cs
- SafeSystemMetrics.cs
- MetabaseServerConfig.cs
- LocalizedNameDescriptionPair.cs
- Vector3DCollectionValueSerializer.cs
- WebPartEditorCancelVerb.cs
- OdbcCommandBuilder.cs
- PropertyDescriptorGridEntry.cs
- VSWCFServiceContractGenerator.cs
- SiteMapSection.cs
- BinaryObjectInfo.cs
- Baml6Assembly.cs
- NegationPusher.cs
- WebConfigurationFileMap.cs
- ReflectEventDescriptor.cs
- XslTransform.cs
- NumberFunctions.cs
- TypeInfo.cs
- EdmFunctions.cs
- ToolStripSplitButton.cs
- ItemType.cs
- ValidationManager.cs
- DataGridCaption.cs
- ResolveDuplex11AsyncResult.cs
- StructuredTypeEmitter.cs
- EntityTypeEmitter.cs
- SeekStoryboard.cs
- SecurityKeyIdentifierClause.cs
- EnumBuilder.cs
- Ref.cs
- SQLCharsStorage.cs
- WebBrowserContainer.cs
- DataViewManagerListItemTypeDescriptor.cs