Using MapPath From A Worker Thread?

Feb 24, 2010

I have a WCF service method that's running in a worker thread I spin from another method. I need to map a relative service app path ("~/Templates/a.template") to the physical path ("D:WebTemplatesa.template"), but I can't use HttpContext.Current.Server.MapPath because HttpContext.Current is null in a worker thread. How else can I reach MapPath method?

View 2 Replies


Similar Messages:

Net - Update A Page From A Worker Thread?

Jul 30, 2010

I have a ASPX page which queries from a database. Once we have the dataset it is bound to a gridview and displayed on the page. All this happens in the Page_Load event.Ofcourse this a simplistic approach. What is the best way to inform the user that data is being retrieved and when we have the data to update the page with the results in the dataset.I want all this to happen within the same ASPX page and do not want to hop around pages to achieve this. I looked at update panels however it wasn't clear to me how this could be done with an update panel without having a control which triggers the update for the update panel. There are no controls on my page whhich initiate the database query, it occurs as the page is loaded

View 1 Replies

Web Forms :: Create Worker Thread In Webpage?

Feb 5, 2010

I am developing an asp.net application which provide a UI for user to submit some kind of job.

Behind the scene, i created a thread to sleep around certain mintues and then process the submmitted job. I would like to ask this is right way to create some worker threads to process the jobs? any risk in threading? any other alternative?

currently, i am facing the timeout of asp.net session. For example, the period of sleeping is 25 mins, the thread will not be processed because the asp.net session is timeout in 20 mins.

View 2 Replies

Change Label.text Value From A Worker Thread?

Feb 7, 2011

i upload a file using ftp, and to not get my GUI stuck i use a thread which do the Job.

I want to display in a label control text value the remaining bytes.

how can do this. (i use VS.NET 2005, Web application)

View 1 Replies

Difference Between Server.MapPath And Page.MapPath?

Sep 23, 2010

What is the difference between those two? If I only want to retrieve the absoluate path to an image on web server, is Server.MapPath safer in any case? I'm using Page.MapPath right now, but it won't work if control was created in WebService since control.Page property become null? Whether Server.MapPath always work?

View 1 Replies

Cross-thread Operation Not Valid: Accessed From A Thread Other Than The Thread It Was Created On

Apr 2, 2010

I want to remove checked items from checklistbox (winform control) in class file method which i am calling asynchronously using deletegate. but it showing me this error message:-

Cross-thread operation not valid: Control 'checkedListBox1' accessed from a thread other than the thread it was created on.

i have tried invoke required but again got the same error. Sample code is below:

[code]....

View 1 Replies

Visual Studio :: Debug A Multi Thread Program To See Local Variables Of Each Thread Using 2008

Jan 27, 2010

How can we debbug a multi-thread program to see local variables of each thread using visual studio 2008.

View 1 Replies

Architecture :: How Can Thread Update A Variable Shared With The Main Thread

Nov 24, 2010

I'm new to threading and have used it successfully, but limited. I can spawn a thread and have the main thread reference variables in the spawned thread, but I don't know how to allow the spawned thread to reference (and update) variables in the main thread.

Any example threading code I've seen on the web appears to be WAY more complicated than what I do, so I am unable to understand or integrate into my code.

Here is a quick example of how I use threading:

[code].....

View 3 Replies

What Are The Differences Between Currently Executing .NET Thread And Win32 Thread

Mar 24, 2010

I am reading the Asp.net security documentation on msdn.I come across these tow terms and get really confused.

# WindowsIdentity = WindowsIdentity.GetCurrent()

which returns the identity of the security context of the currently executing Win32 thread.

# Thread = Thread.CurrentPrincipal

which returns the principal of the currently executing .NET thread which rides on top of the Win32 thread.

View 1 Replies

C# - Lock Thread.sleep Not Working With .NET Thread?

Jun 25, 2010

I have a password page and when someone enters an incorrect password I want to simply foil a brute force attack by having

bool isGoodPassword = (password == expected_password);

lock (this)
{
if (!isGoodPassword)
Thread.Sleep(2000);
}
I would expect that this would allow all correct passwords without stalling, but if one user enters a bad password another successful password from a different user would also be blocked. However, the lock doesn't seem to lock across ASP.NET threads.

View 4 Replies

Web Forms :: Use Thread.sleep Method For A Particular Thread?

Aug 27, 2010

I want a example of multithreading .i want to use it in a web form not on console.i am using C#.net .and how to use thread.sleep method for a particular thread.

View 5 Replies

Where To Use Mappath And Where Not To Use Mappath

Jan 29, 2010

i added a fileupload,a image and a button in my form and i did this code:

Code:

[code]....

and it did not work at all.........

it was just a wild guess to remove the mappath and it worked though

now from the very begining i am having confusion with this mappath.....

so can someone explain me when and where to use mappath and where not to use mappath?

View 15 Replies

How To Use Attributes As Mappath In Mvc3

Mar 19, 2011

In mvc1, we can write an attribute as '[NewPath("mainpage", Controller = "BrowsePdts", Action = "Index")]' before Action for 'mappaththen we can do sth. as 'mappath' in webformI just want a navigate in the top of page , as ' book
>> magazine >> fashion 'but what the attribute change to in mvc3?

View 3 Replies

Server.MapPath Not Accepting UNC URL?

Mar 2, 2011

I'm having a bit of trouble loading an XML file with ASP. This is the location of the XML file (it's a UNC url):

\ilife104 eamdiskSharedIntegrationSystemdevDataprcImportFactSetFeedsfileList.xml

And this is my code:

<%
'load the XML file..
Option Explicit
Response.Buffer = True
Dim xml
Set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = False
xml.load (Server.MapPath("\ilife104 eamdiskSharedIntegrationSystemdevDataprcImportFactSetFeedsfileList.xml"))
Dim name, retrieved
name = xml.documentElement.childNodes(0).text
retrieved = xml.documentElement.childNodes(2).text
Set xml = Nothing
%>

It gives the error:

Server.MapPath() error 'ASP 0174 : 80004005'
Invalid Path Character(s)
/ITWeb/Interfaces/je/index.asp, line 9
An invalid '/' or '' was found in the Path parameter for the MapPath method.

View 1 Replies

Result For MapPath Using This Variable?

Feb 12, 2011

I have this variable that holds a path. I want to see the result for MapPath using this variable, but I get this error.

string FolderName = "Docs/1/1232"
'Server.MapPath(FolderName)' threw an exception of type 'System.Web.HttpException'

Stack trace: at System.Web.Configuration.UserMapPath.GetPhysicalPathForPath(String path, VirtualDirectoryMapping mapping)
at System.Web.Configuration.UserMapPath.GetPathConfigFilename(String siteID, VirtualPath path, String& directory, String& baseName)
at System.Web.Configura [code].....

View 1 Replies

How To Use Server.MapPath When HTTPContext .Current Is Nothing

Jan 20, 2011

I have some code that works fine when I need to delete some image files from a directory on my web server:

Dim ImageURL As String = dsImages.Tables(0).Rows(iImgRow).Item("ImageURL")
Dim physicalName = Server.MapPath(ImageURL)
oUpload.DeleteFileFromServer(physicalName, iAdid, iImgID)

.but I am running into a problem when a maintenance task running in a separate thread at set intervals determines that files like the above need to be deleted:

Dim ImageURL As String = dsImage.Tables(0).Rows(i - 1).Item("ImageURL")
Dim iImgID As Integer = dsImage.Tables(0).Rows(i - 1).Item("ImageId")
Dim physicalName As String = HttpContext.Current.Server.MapPath(ImageURL)
oUpload.DeleteFileFromServer(physicalName, iAdID, iImgID)

In this latter case, HttpContext.Current.Server.MapPath(ImageURL) has a value of Nothing.Is there a way to get the full path for this case?

View 1 Replies

Access :: OleDbConnection - Use Server.Mappath

May 6, 2010

I want to make an oledbconnection for my access database. I want to put the connection string in the web.config but I learned that server.mappath does not work in there. I want to use the server.mappath. Can I put the connection sting in a session variable into the global.asax in the session start?

View 2 Replies

Where Does Httpcontext.current.server.mappath Start

Jan 15, 2010

Where does httpcontext.current.server.mappath start?

I don't get it... it doesn't return a path.

My webservice is ran when I debug my application :S.

View 4 Replies

Save A Picture In One Folder Up From There Where Call The Mappath?

Mar 28, 2011

i want to save a picture in one folder up from there where i call the mappath how can i do that?

for example i am here

c:usersmevstproject

and i want to save the file here

c:usersmevst

i want to do that with mappath in order to work in the server.not only in my pc..

View 9 Replies

How To Use Server.MapPath To Get Location Outside Website Folder

Aug 6, 2010

When my ASP.NET site uses documents (e.g. XML), I normally load the document as follows:

Server.MapPath("~DocumentsMyDocument.xml")

However, I would like to move the Documents folder out of the website folder so that it is now a sibling of the website folder. This will make maintaining the documents considerably easier.

However, rewriting the document load code as follows:

Server.MapPath("../../Documents/MyDocument.xml")

results in a complaint from ASP.NET that it cannot 'exit above the top directory'.

how I can relatively specify the location of a folder outside the website folder? I really don't want to specify absolute paths for the obvious deployment reasons.

View 4 Replies

State Management :: Using Server.mapPath After Application_End

Jan 13, 2011

in my Global.asax I have a timer and every 24 hours it creates an instance of a class and calls a method to send reminder emails with an attachment. In this method I am getting the current HttpContext and using Server.MapPath to get the path to the attachment, but it is always null. I guess this is because Application_End has been called between the last user accessing the site and the method being called.

As a workaround I am setting the timer interval to 19 minutes but I would rather not call the method 36 times a day when only once is required.

Is there any way, apart from hard coding the path, to ensure the HttpContext is not null?

View 5 Replies

VS 2008 Server.MapPath Returning Incorrect Path?

Apr 17, 2010

The layout of my web app is C:inetpubwwwroot<sln folder><web app folder>. So the image folder in my web app would be the previous path images.

When I try to save to my images folder from a FileUpload control and use Server.MapPath, it drops my <sln folder>, so the path is incorrect. How do I fix this? I figured Server.MapPath just moved up the folder until it hit a drive, no?

View 4 Replies

C# - Server.MapPath() Returning A Path That Does Not Exist When Used With DirectoryInfo?

Jul 20, 2010

I have a virtual directory setup in IIS6. This maps to a shared network drive.

I can correctly map the path using

string mappedPath = HttpContext.Current.Server.MapPath(path);

I then create a DirectoryInfo object as I want to find some files in the directory.

DirectoryInfo updateDirectory = new DirectoryInfo(mappedPath);

But then updateDirectory.Exists is false?? I can take the string from the mappedPath and copy into Start->Run to get to the path so I know it exists. I am authenticating to the webservice using integrated windows authentication and have permissions to the necessary folders.

Is there something obvious I'm missing in the code? Or is this purely set-up and configuration of IIS etc.?

View 2 Replies

Server.MapPath Not Returning Full Path Of A File?

Jan 10, 2011

I have image files stored in "VS_ProjectResourcesImages".

When I use the following code:

String str = Server.MapPath("a.png");
str becomes "VS_Projecta.png".

Why isn't it returning the full path?

View 1 Replies

Web Forms :: Server.MapPath Displays Path As Relative?

May 4, 2010

I have a web application that uses Server.MapPath to specify the exact physical path of as part of upload image.

For example if I do Server.MapPath("/")

I get this:

\boswinfs04homeusersweb2676username

I was expecting something like this:

d:folder

I need to use Server.MapPath not only for image upload but several other uses.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved