• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Web.HttpServerUtilityBase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Web.HttpServerUtilityBase的典型用法代码示例。如果您正苦于以下问题:C# HttpServerUtilityBase类的具体用法?C# HttpServerUtilityBase怎么用?C# HttpServerUtilityBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HttpServerUtilityBase类属于System.Web命名空间,在下文中一共展示了HttpServerUtilityBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: getCacheFilename

        /// <summary>
        /// Calculate a unique filename representing this request.
        /// </summary>
        public string getCacheFilename(string query, bool withGzip, 
            HttpServerUtilityBase server)
        {
            Debug.Assert(!string.IsNullOrEmpty(cacheDir));

            //
            // lowercase the query, and hash it
            //
            byte[] MessageBytes = Encoding.ASCII.GetBytes(query.ToLower());

            SHA1Managed sha1 = new SHA1Managed();
            byte[] sha1Bytes = sha1.ComputeHash(MessageBytes);

            StringBuilder sb = new StringBuilder();
            sb.Append( Convert.ToBase64String(sha1Bytes) );

            //
            // replace any invalid path characters
            //
            foreach(char c in Path.GetInvalidFileNameChars()) {
                sb.Replace(c, '_');
            }

            //
            // use a distinct key for gzipped content
            //
            if (withGzip)
            {
                sb.Append(".gz");
            }

            string relPath = Path.Combine(cacheDir, sb.ToString());
            return server.MapPath(relPath);
        }
开发者ID:gmoothart,项目名称:NCombo,代码行数:37,代码来源:ncombo.cs


示例2: PRCImageCollection

        public PRCImageCollection(HttpServerUtilityBase Server, string PRCRef)
        {
            this.PRCRef = PRCRef;
            this.ServerPath = new DirectoryInfo(Server.MapPath(@"~\"));

            this.CarouselImagesDirectoryPath = new DirectoryInfo(this.ServerPath + "CarouselImages\\" + PRCRef);
            this.PropertyImagesDirectoryPath = new DirectoryInfo(this.ServerPath + "PropertyImages\\" + PRCRef);

            //get all directories and files and create PRCImages
            GetAllImagesFromADirectoryAndPlaceInACollection(CarouselImagesDirectoryPath, CarouselImageList, this.CarouselImagesExists);
            GetAllImagesFromADirectoryAndPlaceInACollection(PropertyImagesDirectoryPath, PropertyImageList, this.PropertyImagesExists);

            if (CarouselImageList.Count > 0)
            {
                CarouselImagesExists = true;
                foreach (var image in CarouselImageList)
                {
                    image.CapitalizeCamelCasedString();

                }
            }
            if (PropertyImageList.Count > 0)
            {
                PropertyImagesExists = true;
                foreach (var image in PropertyImageList)
                {
                    image.CapitalizeCamelCasedString();

                }

            }
        }
开发者ID:nadavdrewe,项目名称:portugalvillas,代码行数:32,代码来源:ImageUtility.cs


示例3: ResolveRelativePath

 private static string ResolveRelativePath(HttpServerUtilityBase server, string physicalPath)
 {
     //C:\@Projects\Tarts\Tarts.Web\assets\images\large\1040c396-c558-473e-a3ca-f20de6ab13d2.jpg
     string relative = "~/assets/images";
     string physical = server.MapPath(relative);
     return physicalPath.Replace(physical, relative).Replace("\\", "/").Replace("~","");
 }
开发者ID:s-leonard,项目名称:Tarts,代码行数:7,代码来源:ImageHelper.cs


示例4: deleteFolder

        public void deleteFolder(HttpRequestBase Request, HttpServerUtilityBase Server)
        {
            //dbContext = new PAWA.DAL.PAWAContext();

            IEnumerable<Folder> folders = GetFolders();

            int foldersIndex = 0;
            string selectedValue;
            while (foldersIndex < folders.Count())
            {
                selectedValue = Request.Form[folders.ElementAt(foldersIndex).FolderID.ToString() + "_folder"];
                int folderID = folders.ElementAt(foldersIndex).FolderID;
                if (selectedValue != null && selectedValue.Equals("on"))
                {

                    Folder delFolder = folders.ElementAt(foldersIndex);
                    deleteFolderChain(delFolder);

                }
                else
                {
                    foldersIndex++;
                }
            }
        }
开发者ID:jarradm,项目名称:PAWA,代码行数:25,代码来源:DeleteFolder.cs


示例5: SaveImage

        public Image SaveImage(HttpServerUtilityBase server, HttpPostedFileBase file)
        {
            string largeUploadFolder = server.MapPath("~/assets/images/large");
            string mediumUploadFolder = server.MapPath("~/assets/images/medium");
            string thumbUploadFolder = server.MapPath("~/assets/images/thumb");
            if (!Directory.Exists(largeUploadFolder)) Directory.CreateDirectory(largeUploadFolder);
            if (!Directory.Exists(mediumUploadFolder)) Directory.CreateDirectory(mediumUploadFolder);
            if (!Directory.Exists(thumbUploadFolder)) Directory.CreateDirectory(thumbUploadFolder);

            //The resizing settings can specify any of 30 commands.. See http://imageresizing.net for details.
            ResizeSettings largeSettings = new ResizeSettings("maxwidth=800&maxheight=800");
            ResizeSettings mediumSettings = new ResizeSettings("maxwidth=300&maxheight=300&scale=both");
            ResizeSettings thumbSettings = new ResizeSettings("width=100&height=100&crop=auto");

            //var uniqueName = System.Guid.NewGuid().ToString();
            string uniqueName = PathUtils.RemoveExtension(file.FileName) + "_" + DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss");
            string largeFilePath = Path.Combine(largeUploadFolder, uniqueName);
            string mediumFilePath = Path.Combine(mediumUploadFolder, uniqueName);
            string thumbFilePath = Path.Combine(thumbUploadFolder, uniqueName);

            //Let the image builder add the correct extension based on the output file type (which may differ).
            var large = ImageBuilder.Current.Build(file, largeFilePath, largeSettings, false, true);
            var med = ImageBuilder.Current.Build(file, mediumFilePath, mediumSettings, false, true);
            var thumb = ImageBuilder.Current.Build(file, thumbFilePath, thumbSettings, false, true);

            Image img = new Image(PathUtils.RemoveExtension(file.FileName), ResolveRelativePath(server, large), ResolveRelativePath(server, med), ResolveRelativePath(server, thumb));
            Repo.Save(img);
            return img;
        }
开发者ID:s-leonard,项目名称:Tarts,代码行数:29,代码来源:ImageHelper.cs


示例6: Delete

 public void Delete(HttpServerUtilityBase server, Image img)
 {
     try { System.IO.File.Delete(server.MapPath(img.Large)); } catch {}
     try { System.IO.File.Delete(server.MapPath(img.Medium)); } catch {}
     try { System.IO.File.Delete(server.MapPath(img.Thumb)); } catch {}
     Repo.Delete(img);
 }
开发者ID:s-leonard,项目名称:Tarts,代码行数:7,代码来源:ImageHelper.cs


示例7: CreateAlbumWithMockFile

        private Album CreateAlbumWithMockFile( AlbumRepository repo, HttpServerUtilityBase server, Mock<HttpPostedFileBase> mock )
        {
            Album album = repo.CreateAlbum( new BackOffice.Model.Album
            {
                Duration = TimeSpan.FromHours( 2 ),
                Title = RandomName(),
                Artist = new BackOffice.Model.Artist { Name = RandomName() },
                ReleaseDate = DateTime.UtcNow,
                Type = "Hip-Hop US",
                Tracks = new List<Track>
                            {
                                new Track
                                {
                                    Number = 1,
                                    Duration = TimeSpan.FromMinutes(4),
                                    File = mock.Object,
                                    Song = new Song
                                    {
                                        Name = RandomName(),
                                        Composed = new DateTime(2010,1,12)
                                    }
                                }
                            }
            }, server );

            return album;
        }
开发者ID:clegendre,项目名称:NwdStudents,代码行数:27,代码来源:AlbumRepositoryTests.cs


示例8: EditCountry

 public ProcessResult EditCountry(int id, string nameRus, string nameEng, HttpPostedFileBase imageUpload, bool deleteImage, HttpServerUtilityBase server)
 {
     Country country = GetCountry(id);
     if (String.IsNullOrEmpty(nameRus) || String.IsNullOrEmpty(nameEng))
         return ProcessResults.TitleCannotBeEmpty;
     if (country == null)
         return ProcessResults.NoSuchCountry;
     country.Translation.En = nameEng;
     country.Translation.Ru = nameRus;
     if (deleteImage && imageUpload == null)
     {
         DeleteImage(country.Image, server);
         country.Image = null;
     }
     else if(imageUpload!=null)
     {
         if (imageUpload.ContentLength <= 0 || !SecurityManager.IsImage(imageUpload))
             return ProcessResults.InvalidImageFormat;
         country.Image = SaveImage(country.Id, StaticSettings.CountriesUploadFolderPath, imageUpload, server);
     }
     Data.SaveChanges();
     ProcessResult result = ProcessResults.CountryEdited;
     result.AffectedObjectId = country.Id;
     return result;
 }
开发者ID:Reidan94,项目名称:ITouristDashboard,代码行数:25,代码来源:CountryManager.cs


示例9: PrepareExcel

        /// <summary>
        /// Prepares the excel.
        /// </summary>
        /// <param name="dataSet">The data set.</param>
        /// <param name="reportName">Name of the report.</param>
        /// <param name="reportTitle">The report title.</param>
        /// <param name="responseBase">The response base.</param>
        /// <param name="serverBase">The server base.</param>
        /// <param name="voyageIds">The voyage ids.</param>
        public void PrepareExcel(DataSet dataSet, string reportName, string reportTitle, HttpResponseBase responseBase, HttpServerUtilityBase serverBase, string voyageIds)
        {
            this.response = responseBase;
            this.server = serverBase;

            this.GenerateGuestReconciliationTable(dataSet, reportName, reportTitle, voyageIds);
        }
开发者ID:JaipurAnkita,项目名称:mastercode,代码行数:16,代码来源:ExcelProvider.cs


示例10: delete_mvc_use_only

        public Boolean delete_mvc_use_only(int id, HttpServerUtilityBase server_context)
        {
            try
             {
                HinhAnh kq = this.get_by_id(id);
                if (kq == null) return false;
                //first delete file
                try
                {
                    String directory = "~/_Upload/HinhAnh/";
                    System.IO.File.Delete(server_context.MapPath(Path.Combine(directory, kq.duongdan)));
                    System.IO.File.Delete(server_context.MapPath(Path.Combine(directory, kq.duongdan_thumb)));

                }
                catch (Exception ex)
                {
                    Debug.WriteLine("qqqqqqqqqqqq"+ex.ToString());
                }
                //delete in database
                _db.ds_hinhanh.Remove(kq);
                _db.SaveChanges();
                return true;
             }
             catch (Exception ex)
             {
                 Debug.WriteLine(ex.ToString());
                 return false;
             }
        }
开发者ID:quocdunginfo,项目名称:CuaHangDTDD,代码行数:29,代码来源:HinhAnhController.cs


示例11: GetEntryPoint

        private static string GetEntryPoint(HttpServerUtilityBase server, string filePath, string root)
        {

            var fileName = PathHelpers.GetExactFilePath(filePath);
            var folder = server.MapPath(root);
            return PathHelpers.GetRequireRelativePath(folder, fileName);
        }
开发者ID:philipooo,项目名称:RequireJSDotNet,代码行数:7,代码来源:DefaultEntryPointResolver.cs


示例12: SwtorzFirme

        internal Firma SwtorzFirme(HttpServerUtilityBase server, HttpPostedFileBase uploadFile)
        {
            string url = string.Empty;
            if (uploadFile != null && uploadFile.FileName != string.Empty)
            {
                url = Path.Combine(server.MapPath("~/Images/firmy"), uploadFile.FileName);
                uploadFile.SaveAs(url);
                url = Path.Combine("../Images/firmy", uploadFile.FileName);
            }

            Firma firma = new Firma
            {
                nazwa = nazwa,
                zdjecie = url,
                adres = new Adres
                {
                    ulica = ulica,
                    numer_budynku = numer_budynku,
                    numer_lokalu = numer_lokalu,
                },
                kontakt = new Kontakt
                {
                    mail = mail,
                    numer_komurkowy = numer_komurkowy
                },
            };

            return firma;
        }
开发者ID:przemko07,项目名称:ZaliczenieTenglera,代码行数:29,代码来源:NowaFirmaVM.cs


示例13: SetCleanExtractFolder

 private static string SetCleanExtractFolder(HttpServerUtilityBase server, string mapPath,
     string cleanFileNameNoExtension)
 {
     var extractFolder = server.MapPath(mapPath + cleanFileNameNoExtension);
     MakeOrResetDirectory(extractFolder);
     return extractFolder;
 }
开发者ID:rswetnam,项目名称:GoodBoating,代码行数:7,代码来源:FileServices.cs


示例14: FileCertificateService

 public FileCertificateService(HttpServerUtilityBase serverBase, IFileSystem fileSystem, string path, string password)
 {
     _serverBase = serverBase;
     _fileSystem = fileSystem;
     _path = path;
     _password = password;
 }
开发者ID:njmube,项目名称:SigningService,代码行数:7,代码来源:FileCertificateService.cs


示例15: EventCategorySingleViewModel

        public EventCategorySingleViewModel(string category, HttpServerUtilityBase server)
        {
            _server = server;

            category = formatCategoryString(category);

            //ImageList = getImageList();

            using (var context = new DataContext())
            {
                var tomorrow = DateTime.Now.Date;
                TheCategory = context.EventCategories.FirstOrDefault(x => x.CategoryName == category);

                EventRoll = context.Events.Where(x => x.MainCategory == category && x.IsActive == true && DateTime.Compare(x.EndDate.Value, tomorrow) >= 0).ToList();

                // Set a random picture on the eventRoll if none is currently set
                //foreach (var event in EventRoll)
                //{
                //	if (String.IsNullOrEmpty(event.ImageUrl))
                //	{
                //		event.ImageUrl = getRandomImage();
                //	}

                //}
            }
        }
开发者ID:marciocamello,项目名称:dirigo-edge,代码行数:26,代码来源:EventCategorySingleViewModel.cs


示例16: FakeHttpContext

        public FakeHttpContext(
            IPrincipal principal,
            IFormParamsProvider formParams,
            IQueryStringParamsProvider queryStringParams,
            ICookieProvider cookies,
            IServerVariablesParamsProvider serverVariablesParams,
            IHeadersParamsProvider headersParams,
            SessionStateItemCollection sessionItems,
            HttpServerUtilityBase server,
            FakeHttpRequest request,
            IHttpContextBehavior contextBehavior)
        {
            User = principal;
            _sessionItems = sessionItems ?? new SessionStateItemCollection();
            _request = request ?? new FakeHttpRequest(formParams, queryStringParams, cookies, serverVariablesParams, headersParams);
            _request.SetIsAuthenticated(User.Identity != null ? User.Identity.IsAuthenticated : false);
            _server = server ?? new Mock<HttpServerUtilityBase>().Object;

            var httpResponse = new Mock<HttpResponseBase>();
            httpResponse.Setup(x => x.ApplyAppPathModifier(It.IsAny<string>())).Returns<string>(s => s);
            _response = httpResponse.Object;

            _behavior = contextBehavior;

            _items = new Hashtable();
        }
开发者ID:mira-network,项目名称:SpecsFor,代码行数:26,代码来源:FakeHttpContext.cs


示例17: AddPlace

        public ProcessResult AddPlace(Place place, HttpPostedFileBase imageUpload, HttpServerUtilityBase server)
        {
            if (Translation.IsInValid(place.Translation) || Translation.IsInValid(place.Translation1))
                return ProcessResults.InvalidTranslations;
            if (GetPlace(place.Translation, place.RegionId) != null)
                return ProcessResults.PlaceAlreadyExists;
            var t = Data.Translations.Add(place.Translation);
            Data.SaveChanges();
            place.Name = t.Id;
            t = Data.Translations.Add(t);
            Data.SaveChanges();
            place.Description = t.Id;
            place = Data.Places.Add(place);
            try
            {
                Data.SaveChanges();
            }
            catch (Exception)
            {
                Data.Places.Remove(place);
                Data.SaveChanges();
                return ProcessResults.Error;
            }

            if (imageUpload != null)
            {
                if (imageUpload.ContentLength <= 0 || !SecurityManager.IsImage(imageUpload))
                    return ProcessResults.InvalidImageFormat;
                place.Image = SaveImage(place.Id, StaticSettings.PlacesUploadFolderPath, imageUpload, server);
                Data.SaveChanges();
            }
            ProcessResult result = ProcessResults.PlaceAdded;
            result.AffectedObjectId = place.Id;
            return result;
        }
开发者ID:Reidan94,项目名称:ITouristDashboard,代码行数:35,代码来源:PlaceManager.cs


示例18: GetFile

        public static ActionResult GetFile(HttpResponseBase Response, HttpRequestBase Request, HttpServerUtilityBase Server,
            string filePath, string fileName, string contentType, string userFileName)
        {
            byte[] value;
            using (FileStream stream = System.IO.File.Open(filePath, FileMode.Open))
            {
                value = new byte[stream.Length];
                stream.Read(value, 0, (int)stream.Length);
            }
            //const string userFileName = "MissionOrder.pdf";
            //const string contentType = "application/pdf";
            Response.Clear();
            if (Request.Browser.Browser == "IE")
            {
                string attachment = String.Format("attachment; filename=\"{0}\"", Server.UrlPathEncode(userFileName));
                Response.AddHeader("Content-Disposition", attachment);
            }
            else
                Response.AddHeader("Content-Disposition", "attachment; filename=\"" + userFileName + "\"");

            Response.ContentType = contentType;
            Response.Charset = "utf-8";
            Response.HeaderEncoding = Encoding.UTF8;
            Response.ContentEncoding = Encoding.UTF8;
            Response.BinaryWrite(value);
            Response.End();
            return null;
        }
开发者ID:andreyu,项目名称:Reports,代码行数:28,代码来源:GraphicsController.cs


示例19: EditRegion

 public ProcessResult EditRegion(int id, string nameRus, string nameEng, int countryId, HttpPostedFileBase imageUpload, bool deleteImage, HttpServerUtilityBase server)
 {
     Region region = GetRegion(id);
     if (String.IsNullOrEmpty(nameRus) || String.IsNullOrEmpty(nameEng))
         return ProcessResults.TitleCannotBeEmpty;
     if (region == null)
         return ProcessResults.NoSuchRegion;
     Region r = GetRegion(nameRus, nameEng, countryId);
     if (r != null && r.Id != region.Id)
         return ProcessResults.RegionAlreadyExists;
     region.Translation.En = nameEng;
     region.Translation.Ru = nameRus;
     region.CountryId = countryId;
     if (deleteImage && imageUpload == null)
     {
         DeleteImage(region.Image, server);
         region.Image = null;
     }
     else if (imageUpload != null)
     {
         if (imageUpload.ContentLength <= 0 || !SecurityManager.IsImage(imageUpload))
             return ProcessResults.InvalidImageFormat;
         region.Image = SaveImage(region.Id, StaticSettings.RegionsUploadFolderPath, imageUpload, server);
     }
     Data.SaveChanges();
     ProcessResult result = ProcessResults.RegionEdited;
     result.AffectedObjectId = region.Id;
     return result;
 }
开发者ID:Reidan94,项目名称:ITouristDashboard,代码行数:29,代码来源:RegionManager.cs


示例20: Del

 /// <summary>
 /// Elimina un album e tutto il suo contenuto
 /// </summary>
 /// <param name="Server">Server object per MapPath</param>
 /// <param name="name">Nome dell'album (e nome cartella)</param>
 public static void Del(HttpServerUtilityBase Server, string name)
 {
     string path = Server.MapPath(BASE_PATH + "/" + name);
     if (Directory.Exists(path))
     {
         Directory.Delete(path, true);
     }
 }
开发者ID:baffo88,项目名称:Funblades,代码行数:13,代码来源:Albums.cs



注:本文中的System.Web.HttpServerUtilityBase类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Web.HttpSessionStateBase类代码示例发布时间:2022-05-26
下一篇:
C# Web.HttpServerUtility类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap