Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

server.mappath

Map the physical file path in asp.net mvc

July 29, 2023 by Tarik

string filePath = Server.MapPath(Url.Content(“~/Content/Xsl/”)); I disagree with the idea that HttpContext.Current is “evil.” It’s not the hammer for every problem, but it is certainly better than, e.g., Session for stuff that it can do OK.

Categories asp.net-mvc Tags asp.net-mvc, filepath, server.mappath Leave a comment

Server.Mappath in C# classlibrary

March 22, 2023 by Tarik

By calling it? var path = System.Web.HttpContext.Current.Server.MapPath(“default.aspx”); Make sure you add a reference to the System.Web assembly.

Categories c# Tags c++, server.mappath Leave a comment

Using Server.MapPath() inside a static field in ASP.NET MVC

December 18, 2022 by Tarik

Try HostingEnvironment.MapPath, which is static. See this SO question for confirmation that HostingEnvironment.MapPath returns the same value as Server.MapPath: What is the difference between Server.MapPath and HostingEnvironment.MapPath?

Categories c# Tags asp.net-mvc, c++, lucene.net, server.mappath, static Leave a comment

Cannot use Server.MapPath

December 15, 2022 by Tarik

you can try using this System.Web.HttpContext.Current.Server.MapPath(path); or use HostingEnvironment.MapPath System.Web.Hosting.HostingEnvironment.MapPath(path);

Categories c# Tags c++, intellisense, server.mappath, visual-studio Leave a comment

How can I use Server.MapPath() from global.asax?

December 12, 2022 by Tarik

You could try System.Web.Hosting.HostingEnvironment.MapPath(). No HttpContext required.

Categories c# Tags application-start, asp.net, c++, global-asax, server.mappath Leave a comment

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa