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)
[code].....
View 1 Replies
ADVERTISEMENT
Jul 6, 2009
Is there a way to look through the cache for all objects in the cache? I'm dynamically creating objects and I need to periodically go through the list to purge out objects I'm no longer using.
View 6 Replies
Jul 27, 2011
I have an asp.net project that's compiled on a server. On that same server I have a windows service that's running methods referenced from the asp.net .dll. Everything works fine except for when the httpcontext.current object needs to be accessed. I'm fairly certain that the cause of the .current being null is that it's referencing the shared library without an actual instance of the site running. In a previous version of the service I was able to find a workaround in asp.net by not using the context, however that is now a last resort as much of the architecture of the site has changed. Is there anyway to create an instance of the site and simulate a current httpcontext for the purposes of the service?
View 2 Replies
Jun 19, 2012
I was working on a scenario where I have to add header to the Response Header.
I added a Response Header like this:- HttpContext.Current.Response.AddHeader("key1", "value1")
After some functional flow I required to add value to same "key1": HttpContext.Current.Reponse.AddHeader("key1, "value2")
thus value in Response Headers look like this:- key1 : value1, value2
I want to avoid the value2 addition to the same keyword key1.
I tried:-
If HttpContext.Current.Response.Headers("key1") Then
HttpContext.Current.Reponse.AddHeader("key1, "value2")
EndIf
But I got the error: This operation requires IIS integrated pipeline mode at HttpContext.Current.Response.Headers("key1")
I have IIS6 running. This [URL] says that it doestn't works if its not IIS7
View 1 Replies
Apr 10, 2011
2003I've implemented Forms Authentication on one particular subfolder on one of my sites. My code works perfectly on my development machine, but there is a slight problem on the live server.If you browse to the admin subfolder, if you are not authenticated, you will be redirected to the login page. The Master Page footer also contains a link to the login page; when the user logs in, that link is supposed to change to a link to the admin page:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim link As HtmlAnchor = FindControlIterative(Me, "Login")
If HttpContext.Current.Request.LogonUserIdentity.IsAuthenticated Then
[code]....
This works fine on my dev PC, but on the live server, IsAuthenticated() returns False, and thus the Login link is not replaced by the Admin link. However, if browse to the admin subfolder, I can access the content fine; there is no redirection to the login page.
View 2 Replies
Feb 29, 2012
I am tring to make the below application work with SQL Server 2005 Database Currently it works for test.mdb, which is in the same folder with the application. How shoud I modify the MapPath to work with SQL Server.
[Code]...
View 1 Replies
Jun 26, 2009
my code is Dim fs As FileStream =New FileStream("C:Documents and SettingsC100492DesktopDocssampleWSxmls" & GadgetName & ".xml", FileMode.Open, FileAccess.Read)
In the above code I have to change the phisical path(C:Document) with Server.mappath. let me know how to write the same code with Server.mappath. I have all xml files in my local application folder(folder name:XML).
View 3 Replies
Feb 28, 2012
I am trying to get get the path of a directory that I have a template file in. ie in asp.net I use
Dim path as string = Server.MapPath("~/Reports/")) and then once I have the Reports dir I can do this
Using r As StreamReader = New StreamReader(path & "Template.htm")
Dim line As String
[code]...
That works great in asp.net but now I need to do the same thing in a console app. I have tried the function path = GetFullPath("~/Reports/") and instead of getting the absolute path to the Reports dir it returns /bin/debug/reports which is wrong. The file Template.htm is not in that directory.
View 3 Replies
Dec 1, 2009
How can i use Server.MapPath in shared methos i tried something lile this [code]...
View 1 Replies
Dec 2, 2009
Ok i have a script that i have been working on for quite awhile and well its not working right i can't figure out how i would use Server.Mappath to show me all the file names from a URI. I have tried using a simple Directory Info but i get a Error "URI not supported" so i saw i can use Server.Mappath but how would i use this?
View 7 Replies
May 2, 2009
i am trying to load contents from a webfolder using the server.mappath .. the server is giving me a error, and i have a feeling i need an import for the code to work...
View 4 Replies
Feb 3, 2009
I am trying to access a file using the following
CODE:
However I am getting the following error: "Object reference not set to an instance of an object."
View 3 Replies
Nov 18, 2010
for a unit test I am trying to add a value to the HttpApplicationState object, which is the Application property of the HttpContext.Current class. I try with the following code
[Code]...
View 1 Replies
Feb 8, 2011
I currently have a web application project that also includes web services within the same project. I currently have a requirement to call the web service asynchronously. Since, I haven't added the web service as a web reference within the same project, I tried to call the web service method using delegates and I see an exception "HttpContext is not available. This class can only be used in the context of an ASP.NET request" when I tried to access the Application property in my web service method call.
[Code]...
View 1 Replies
Sep 22, 2009
This is my first post on the .Net Forums - I hope I don't break any rules in the first post,I'm trying to make a VB based .Net page return a file to the user from a location external to the website.The file itself is a software setup that needs to site outside the Web Directory, basically, the page needs to pick up this file and send it to the user when the page is loaded, I've done some research into the problem and it does seem that ASP .Net will not be able to let the user download files from outside the WebDirectory (in this case, WWWROOT).
Does anyone know if this can be done? I've pasted the code I'm playying about with below - but, I wouldn't be suprised if this is completely wrong
[Code]...
View 1 Replies
Jan 5, 2012
Im having a problem understanding if accessing httpcontext inside a shared function, without passing in the httpcontext as a parameter is thread safe?
Are the 2 functions in the util class equally thread safe?
Class foo
Sub main()
Dim qs1 = util.getQS(HttpContext.Current)
[Code]....
View 2 Replies
Nov 26, 2009
How to retrieve the current datetime of Server in LAN?
View 4 Replies
Dec 20, 2009
Im writing a program that does some general network stuff
i need to set a dns server for the program/current sub "not for the current host pc"
something along the lines of
system.net.dns.setdnsserver = (myspecifiedip)
View 3 Replies
Dec 13, 2011
Basically what I need to do is to insert into table Reservation a vehicleID, startDate and endDate.
I can do that fine but I'd like to validate it so that it cannot be inserted for that vehicleID if the current date is <= endDate as currently I can just keep adding to the Reservation table on the same vehicleID
This is just the simple insert SQL statement.
strInsert = String.Format("Insert into Reservation (VehicleID, startDate, enddate) VALUES ('{0}','{1}','{2}')", vID, now, now5)
View 3 Replies
Aug 3, 2009
How to get userID of current user logged in from server using asp.net vb?
View 2 Replies
Jun 21, 2010
I am a ASP Classic Programmer, professionally for a little over a year, I have developed some rather nice sites, including the one in my signature (Still a work in progress).
I have been forced to use ASP.NET (VB) for a FileUpload control, as it offers a self controlled way of creating Thumbnails, without the use of 3rd party controls, which is great, as my hosting server does not allow for 3rd party installs on their servers.
So.
The code below is what I have so far for connecting to the database and displaying a record is the "cookie" exist on the users computer.
Unfortunantly, this is not working, and to be honest with you, their is not a whole lot of resources available to show how to do this correctly.
So I am stuck with a lot of post and hoping that someone can actually assist me with this and tell me what I am doing wrong and maybe correct my code.
I am getting an error about the "Connection is closed"
If you want to re-write my code, I prefer something simple and basic, as the only thing that I am doing to checking rather the user is logged in, and if so, display a record from the database. I am NOT in the need for the DataGrid, so please do not suggest it, as I am only needing to check this one thing.
I would like to also add, that I have successfully contect to my database with the FileUpload control and save file names of the images uploaded, so I know that my connection string is done properly> But, for some reason the "SELECT" statement is causing a HUGE issue. (It was easier to insert, than to select, I am not use to that)
CODE:
View 4 Replies
Oct 2, 2009
I have this code for my update checker. It loads a blank text file on my server containg the current version. I have it set to naviagte to this url then searches the web browser for the current version. If it cannot find it then there is a newer version, and a button becomes visible which lunches a webpage that has the current version. I would like it to loop my Check_for_update code until the webbrowser1.statustext = "Done" Below is the code i have but it doesnt work for some reason. Private Sub Update_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
[Code]...
View 6 Replies
Aug 8, 2011
Question: How to pass the current user on the web page from the IIS server to the Reporting Services Server.I have seen this topic throughout the forums. However, the answers are always hard code the user in web.config - use a login window and pass those fields to the IReportServercredentials or create one user for everyone.
When the person who asks the question comes back and says that doesn't work there is not answer.Does anyone know how to do this? I have VS 2008 ( and 2010 ) I am sending the info to SSRS 2005 server.As anyone using SSRS knows that if the reports have parameters and udf behind the report to inspect who the user is, then you have to pass that user to the report.
[Code]...
I have been programming steady with vb.net for a year now and was all happy about using the List view and email etc from web sites. I even used a reportviewer to pdf to email attach, cool. Now I feel quite lost and realize I have not been using properties, etc. That is my background.
View 7 Replies
May 8, 2012
We are thinking about changing our current database system, MS Access 2007 front end and MS SQL Server 2005 backend to using a higher level language such as Visual Basic .Net. I wonder if this is the BEST solution for data management? Currently, among others, we have two big database programs that handle more than two hundred users and it's crashed often. That's the reason we think about changing to something that can handle these database programs effectively preferably using MS technology such as .Net.
View 12 Replies
Dec 28, 2011
I have following link in a.aspx file:
<a href="a.htm" target="iframe">A</a>
I want to set link from a.aspx.vb page according to what person is viewing the page. How can i change this so that if user clicks on link it will replace current frameset contained in current window with a url provided according to user?
Or in another way:
How will i replace href code in aspx page by giving it value from aspx.vb page?
View 1 Replies
Sep 20, 2011
Is that possible to get current Enumerator (...or iterator? Don't know which tern is the correct one) in a LINQ query ? For example, I try to create a XML output (via LINQ to XML) of all currently loaded assemblies. [code] is it possible to somehow get current "index" (counter?) from LINQ's Selects? I would like to use it in XML. [code]
View 1 Replies
Sep 12, 2011
I have a datagridview having 3 columns (qty,scraft factor,actuall qty). What I want is if the user encode 50 in qty and 2 in scraf factor, actuall qty will automatically computed based on qty multiply by 2. I was using keyup event. Now I am using endedit to get the current value of the current row and column, now the problem is if the amount to be encoded is more than one digit it will not accept because of endedit. What event do I have to used? or any solution with this scenario.
[Code]...
View 1 Replies
May 17, 2010
How do I force users to save the current record (if current record has changed) and not let user go to the next record unless the save button is pressed?
View 5 Replies
Sep 7, 2010
I am using stored procedures in my application using vb.net, while executing stored procedures on mysql database server thru application, the response time from the server is more. Is there any settings that i need to set on mysql db server or any changes in connection string or in code.
View 14 Replies
May 29, 2012
I have an application I have developed which works great on individual PC's. However I've had some interest from a few customers that asked if I have a network version for site licencing.If my app did not save any data or write any reg entries, this might have been ok. But it does to the local computer. I also built in my own copy protection and trial function that stores data in the registry on the local computer.What would I need to do to enable my application to run on a server/network share, so that the only a serial number needed is for the server?
View 3 Replies