server.mappath does not work on production server can view video using server.mappath

I am trying to use server.mappath to view video which is saved in folder on the server.It does not show the video .If I try to access the video using my ip address

on the server I can see it,but not through server.mappath.

Things are ok on development machine.

Please help.I am using windows media player to view the video.

<div id="VideoDisplay">

<object id="msnVwmp"

classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" style="width: 250px;

height: 250px; position:absolute;left:0px; top:10px" type="application/x-oleobject"

standby="Loading Windows Media Player components...">

<param name="uiMode" value="full"/>

<param name="url" value="<%Video%>"/>

</object>

In my *.cs File I have

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

public partial class SelectVideoImage : System.Web.UI.Page

{

//This page gives links to view video or images.Videos and

//images are stored in respective folders.To view images

//javascript function is used.see the html page.

private string _clip;
public string Video

{

set

{

_clip =
value;

}

get

{

return _clip;

}

}

protected void Page_Load(object sender, EventArgs e)

{

//Session["HyperLink1"] = "LinkVideo1";

//Session["LinkVideo2"] = "LinkVideo2";

 

 

}

protected void LinkButton2_Click(object sender, EventArgs e)

{

Panel1.Visible =
true;

 

Video = Server.MapPath("~/Videos/senegal.wmv");

}

}

I am not able to see the video.Please helpI have videos in the folder Videos.

0
Rekhad
11/10/2008 3:39:57 PM
asp.net.client-side 24353 articles. 1 followers. Follow

14 Replies
1346 Views

Similar Articles

[PageSpeed] 13

Shouldn't this be: <param name="url" value="<%= Video %>"/>

NC...

0
NC01
11/10/2008 4:00:38 PM

Sorry I mistyped that I am using <%=Video%> to view the video,but cant see on production server

0
Rekhad
11/10/2008 4:13:55 PM

Well then your wmv file is not where you are mapping to as I just tried your code and it worked. Using Server.MapPath("~/Videos/senegal.wmv") the sub-folder "Videos" must be located in the exact same folder as the web application.

NC...

0
NC01
11/10/2008 4:49:30 PM

It always works on local machine but not on productuion server.I have copied all the files in exactly same folders as I have on my local machine.The directory structure is

local machine

C:\myname\webapplication_name\Videos (here I have my video files)

on server

domain name:myname.com

In this domainname, created a directory webapplication_name and created a subdirectory Videos

under webapplication_name.Copied video files in Videos folder

so the path for the video is folder on server should be

http://myname.com/webapplication_name/Videos/senegal.wmv

but server.mappath does not work with server.mappath("~/Videos/senegal.wmv")

 

0
Rekhad
11/10/2008 6:09:51 PM

Well Server.MapPath("~/Videos/senegal.wmv") is going to evaluate out to something like C:\Inetpub\wwwroot\web-application-name\Videos\senegal.wmv so if it is not, there is your problem.

I would add this line to your Page_Load handler in each place and see what the difference is:
     this.Response.Write("Server.MapPath: ->" + Server.MapPath("~/Videos/senegal.wmv") + "<-<br>");

Other than that we can't really help with something like that from here as we don't have access to the servers, whereas you do.

NC...

0
NC01
11/10/2008 6:29:33 PM

I was able to find out the path on the server where my video files are.

But even if use the absolute path to view my video I am unable to see it

ie instead of using

Video=server.mappath("~/Videos/myvideo.wmv");

i used

Video="D:\\home\\domain_name.com\\weapplication_name\\Videos\\myvideo.awmv";

but I cant see the video.Please help

0
Rekhad
11/12/2008 2:31:15 PM

How can we help? Have no idea what the problem is. Permissions maybe?

NC...

 

0
NC01
11/12/2008 2:35:05 PM

My hosting provider is saying that sometimes absolute path doesn't work with asp.net (which I doubt ?)

do you have any idea?

0
Rekhad
11/12/2008 4:05:07 PM

Rekhad:

My hosting provider is saying that sometimes absolute path doesn't work with asp.net (which I doubt ?)

do you have any idea?


How could that be possible if it works using an absolute path on your pc? Same ASP.NET. We could try using a relative path: ResolveUrl("~/Videos/senegal.wmv") or ResolveClientUrl("~/Videos/senegal.wmv")

Or try this using an absolute URL. Maybe we'll get lucky:

string qualifiedFilename = "Videos/senegal.wmv";
Video = string.Format("{0}{1}/{2}",
      this.Request.Url.GetLeftPart(UriPartial.Authority),
      this.Request.ApplicationPath,
      qualifiedFilename);

NC...

0
NC01
11/12/2008 4:33:16 PM

Thank you .I will try to put this code on server and check

0
Rekhad
11/12/2008 4:55:43 PM

Tonnes of  thank you!!

It worked. I was struggling with  this issue for a long time.

0
Rekhad
11/12/2008 5:00:46 PM

Which one worked? The absolute URL or the relative filepath?

NC...

 

0
NC01
11/12/2008 5:02:21 PM

The absolute path worked.

Though I would like to know what does this code do here?

0
Rekhad
11/12/2008 5:17:09 PM

Produces an absolute URL such as http://domain_name.com/webapplication_name/Videos/senegal.wmv rather than the qualified file path like D:\home\domain_name.com\webapplication_name\Videos\senegal.wmv

NC...

0
NC01
11/12/2008 5:23:52 PM
Reply:

Similar Artilces:

server.mappath does not working on production server cant see video using server.mappath
I  am not able to use server.mappath on production server.I am trying to download a video file through a windows media player control. It works ok on local machine but not on production server<div id="VideoDisplay"> <object id="msnVwmp" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" style="width: 250px; height: 250px; position:absolute;left:0px; top:10px" type="application/x-oleobject" standby="Loading Windows Media Player components..."> <param name="uiMode" value="full"/> ...

Server.MapPath works on local but not server
Hi,For some strange reason my code has broken, and its due to Server.MapPath not returning the correct path.It works ok on my development machine, but stops working when its live on the server.I've created a test page to try and debug where it is failing.What I've found out is this: It works ok on local, but returns nothing on the server, specifically when the Server.MapPath is being called inside a class.  So when its called withhin a class on my development machine it is ok.Any ideas what is going wrong?Thanks   Hi swaino ,           I th...

Server to Server, both Servers in same Tree
Hi, where could be problem when some time connection is not established after server restart, but some time it is OK. (I waited whole day) Filters are opened for all IP from and to both servers in VPN. Both servers are BM3.7 SP2, NDS Version 10350.19 March 18, 2003 Slave server contain RW replica of the container where the server resides. (I tried also Master replica) here are also licenses for NW6 and BM3.7 Master server is in different replica which is not on slave server. Both servers are on same subnet. Packet capture shows only IP 57 communication from Master to ...

This version of Microsoft Sql Server Management Studio can only be used to connect to Sql Server 2000 and Sql Server 2005 servers
When I connect SQL Server 2005 to a remote database i get the error: "This version of Microsoft Sql Server Management Studio can only be used to connect to Sql Server 2000 and Sql Server 2005 servers". Can I confirm it is because: the remote db is of SQL Server 2008? There is a soln mentioned in http://forums.asp.net/t/1324047.aspx Did anybody try this (installing 2008 express: http://www.microsoft.com/express/sql/download/)? I am just checking again, whether it will disturb my existing SQL Server installation, in any means...? Though it is mentioned that it will g...

How can I use a linux server as a proxy between a DataSnap server/client
I have a DataSnap Server that is behind a NAT firewall. I also have many DataSnap clients that need to connect to that server. I want to provide a connection proxy to help those two computers connect and transfer data. The server will be authorized for this service ahead of time and I thought the best way would be to have a dedicated port on my Linux servers IP for each server needing my connection service. I have thought about L2TP type of VPN connection from the server to my linux server. It would be nice if I could create scripts/batch files on both ends to automate the install and make th...

server or no server
i have been looking in to slipstreaming windows up dates over the net work ..i have also been thinking (bad thing to do ) installing the os over the net (image).i know you can do this over win2k server using rras server but could i do this in novell 5.1 with out bulding and paying for a server lience. our network is spread across 6 sites one server to each site a gig backbone on each site but connect by 100 mb line .not knowing novell to well but they seem not to be use the OS and Server to well .any help or info would be useful Nigel, > i have been looking in to...

Firing both Client side event and server side event for server side button
I am having some difficulties getting this to work.. I have button_click (Asp.net) and ClientClick (Javascript).  Javascript is firing fine.  Server script is not. may be you have return return false in the in the javascript which is why its not firing server side event.You should add javascript evelt like thisbutton1.onclientclick = "functionname" Function should nopt return false. Vikram www.vikramlakhotia.comPlease mark the answer if it helped you...

When to use client side varidation and server side varidation in .net?
In .net or classic web application we can varidate user data either on client isde or server side. How to select which side varidate to be used? Thanks! Generally, I use both client and server validation. I make sure the input is in the correct format and reasonably valid on the client, then I verify the data on the server. The extent of validation also depends on the type of data that I need to validate.Here are a few references:Validating ASP.NET Server ControlsIntroduction to Validating User Input in Web FormsClient-Side Validation for ASP.NET Server ControlsSecurity Checklist...

Can't Connect .Net application from Windows Server 2003 to Database Server (SQL Server 2000)
Hi, I am having a problem connecting my .net applications from the application server to the database server. When I run the application from my windows xp (sp2) box it works fine. When I try to connect via SQL Management Studio to the database server from the application server I get the same error. Here is the error: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider...

Server Side Includes (SSI) using VS.NET 2005 Built-In Development Web Server
Background Information:  I am developing an ASP.NET application using VS.NET 2005 and the built in development web server without having IIS installed on my development machine.  I cannot install IIS on my development machine due to company policy.  For the production environment, the application will be running in Windows Server 2003 with IIS 6.0.  There are a set of components that my company uses that I must use within the application.  The components, when installed on the server, exist under IIS at the same level/directory (<MachineName>\Web Sites\Def...

Client & Server Side ( Server PostBacks Reset Client Data )
Hi, Slight Problem i have bumped into, maybe someone can help me... --TestSlider.aspx--------- <%@ Page Language="C#" %> <script runat="server"> void click(object sender, EventArgs e) { Label1.Text = Label1.Text; if(btnPress.Text=="Press") btnPress.Text = "PRESS"; else btnPress.Text = "Press"; } </script> <html> <head> <script language="JavaScript"> function newSlider(sId) { sCode = '<table border=...

can I use Server.MapPath() in a class?
There will be error "  "Server" name not declared" when I use Server.MapPath()  in a vb.net class. I have already imports System.Data.OleDb and system.data Could anyone tell what is going wrong? Thanks!     Hi, in order to be able to use that in a class you should prefix it with HttpContext.Current. So it becomes HttpContext.Current.Server.MapPath(...). Also please read this post: http://aspadvice.com/blogs/joteke/archive/2006/04/23/16785.aspx. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons. ...

automation server to client and client to server
I have to applications that need to communicate with each other. Is it practical for both of them to be servers and clients to each other? One of the applications will work primarily as a server and will launch the other application. The newly launched application needs to be able to send occasional information to the server to update information in the application that launched it. Also, if the user attempts to close the launched application it needs to tell the launcher application to close the appl ication that it launched. Does this sound practical? This is kind of like launching wo...

Server.transfer suddenly not working on production server.
Hi, Ive recently launched an asp.net application running on an externally hosted server which makes extensive use of server.transfer as a means of passing users between pages. This worked perfectly on both my development workstation and the hosting plan webspace up until friday last week where all my server.transfer dependant web controls suddenly stopped working. After a number of furious re-uploads and now, a swapping of all server.transfer with response.redirects, nothing is working .... Although the code works perfectly on my workstation and up until the problems on friday - wo...

Web resources about - server.mappath does not work on production server can view video using server.mappath - asp.net.client-side

Video production - Wikipedia, the free encyclopedia
Video production is videography , the process of capturing moving images on electronic media (e.g., video tape , direct to disk recording , or ...

OPEC 'dead' as oil countries go it alone on price and production
OPEC has abandoned all pretence of acting as a cartel. It's now every member for itself.

TAG Heuer Connected demand forces production increase, new models coming in 2016/17
TAG Heuer has had to almost double its production to meet demand for its first Android Wear luxury smartwatch. The TAG Heuer Connected is based ...

TAG Heuer smartwatch production to be increased due to high demand
Swiss watchmaker TAG Heuer announced that it will be increasing the production of its TAG Heuer Connected smartwatch, in order to meet the anticipated ...

Faster fifth-gen Apple TV to enter production in early 2016
According to a recent report out of Taiwan, Apple is planning on beginning trial production of a new, fifth-generation Apple TV device in early ...

Citroen E-Mehari is wild enough to go into production
Filed under: Green , Citroen , Europe , Convertible , Electric Citroen reveals its E-Mehari, a funky cabriolet that will begin production early ...

Porsche approves production version of the electric Mission E concept
The automaker believes it will arrive in showrooms around the end of the decade.

Reports of slowing iPhone production may be greatly exaggerated
Reports that iPhone 6s production may be slower than expected may be plain wrong, if you go by the record earnings one iPhone supplier recorded ...

Production Designer Judy Becker On Creating Period New York City For ‘Carol’ And ‘Joy’
A frequent collaborator of directors Todd Haynes and David O. Russell , production designer Judy Becker is back this year with new films from ...

Inventec to undertake ODM production of 12.5-inch notebook for Xiaomi
Taiwan-based Inventec will undertake ODM production of a 12.5-inch notebook model for China-based vendor Xiaomi Technology at its factory in ...

Resources last updated: 12/12/2015 12:09:56 AM