I have a shared folder containing a list of wav files i wish to open this files from my asp.net application.
everything is working good when we launch our application from loaclhost but after deploying it it is not workin ( it can not find files)
my code :
Dim oDirectories As String() = Directory.GetFiles("\\192.168.1.160\records\Files\" & dateC & "\", "*.wav")
Dim files As List(Of String) = (From q In oDirectories
Where q.Contains(indice)
Select q).ToList()
Dim liststrings As Integer = files.Count
ListBox1.DataSource = files
ListBox1.DataBind()
When you saying "deploying" - what do you actually mean - to a public/hosting server? Realize that you are using a private IP - which in, and of itself, doesn't always point to the problem (it's possible, depending on your type of hosting account - re: dedicated subnet), but based on the info you provided, that would be where to look first.
Related
I have come across a bit weird problem with classic asp site which uses indexing service to search folder by given parameter and then lists files from the folder. Folder names are unique so the query should return only one recordset. Site is running at w2k8 64 environment. Before it was running in w2k3 server.
Basically everything runs okay but at some rare cases with specific folders query doesn't return anything at all. And this happens only if I go to the site from remote location. If I go to the site at localhost everything works just fine with those problematic cases.
Here is the code block
Dim strQuery
strQuery = "#all " & target & "*"
Set ixQuery = Server.CreateObject("ixsso.Query")
ixQuery.Query = strQuery
ixQuery.Catalog = "Reports" '
ixQuery.SortBy = "create [d], filename [a]"
ixQuery.Columns = "DocTitle, path, filename, size, create, directory"
ixQuery.MaxRecords = 150000
Dim util
Set util = Server.CreateObject("ixsso.Util")
util.AddScopeToQuery ixQuery, Server.MapPath("Reports"), "deep"
Sim queryRS ' Query recordset.
Set queryRS = ixQuery.CreateRecordSet("nonsequential")
Has anyone came up with same kind of problem? Any ideas how to solve it?
Update: I rewroted the program in ASP.NET because it wouldn't work as classic asp.
I am developing a web application in asp.net web forms framework. one of the requirement of application is to save records of future appointments of user. User also want to add this appointment to his outlook calendar. Now the problem is that my code is working locally. Appointments are being saved when I test application on my local machine. But when I deploy application on live server code give error and appointment do not saves in my outlook calendar. Kindly help me how to make it work on live server. Following is the code I'm using
Private Sub AddToCalander()
Try
Dim olApp As Microsoft.Office.Interop.Outlook._Application = DirectCast(New Microsoft.Office.Interop.Outlook.Application(), Microsoft.Office.Interop.Outlook._Application)
Dim mapiNS As Microsoft.Office.Interop.Outlook.NameSpace = olApp.GetNamespace("MAPI")
Dim profile As String = ""
mapiNS.Logon(profile, Nothing, Nothing, Nothing)
Dim apt As Microsoft.Office.Interop.Outlook._AppointmentItem = DirectCast(olApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem), Microsoft.Office.Interop.Outlook._AppointmentItem)
apt.Subject = ddItineraryItems.SelectedItem.Text
apt.Body = txtPItinerary_Desc.Text
apt.Start = CDate(txtDateFromPopup.Text)
apt.End = CDate(txtDateToPopup.Text)
apt.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olTentative
apt.AllDayEvent = False
apt.Location = dcmbDealer.SelectedItem.Text & "," & dcmbShowroom.SelectedItem.Text
apt.Save()
Catch ex As Exception
AlertMessage.showError("Unable to add itinerary detail to outlook calendar")
Exit Sub
End Try
End Sub
I get the code from here.
http://www.codeproject.com/Tips/384326/Add-to-Calender-Adding-event-to-Microsoft-Outlook
If you are going to use Outlook by Interop, then you would need to install it on your server. Without installed Outlook - it won't work.
PS. Your code will work only with Outlook account that is configured by default. And it will work only if you are using external service for appointments. Otherwise it will save that appointment just to Outlook on server, without updating it to your local Outlook
And using Interop in web applications on server side isn't a good idea, as it will starts new Outlook process every time, that is very resource expensive. Better way is to integrate with Calendar system that you are using, like Google Calendar, etc.
I've been working on a site to allow clients to sftp data files to us (using SharpSSH.dll) My solution works fine on my development machine but as soon as I move it to production server I am unable to upload.
I know that the problem is because my code is trying to pick up a file on the server when it obviously doesn't exist there so I need some pointers on the best way to resolve this - i.e. how do I adjust my code to allow for an sftp upload from the client machine?
The plan is basically to (and im not entirely sure that I am going about this the correct way) use my web server as a go-between so the client logs on and sftps a file to another server. Advice and pointers are very welcomed - please see code below:
transfer = New SecureFileTransfer("IP", "PORT", "NAME", "PASSWORD")
If transfer.putFile(FileUpload.PostedFile.FileName, company & "/" & filename) = True Then
lblMsg.Text = "File upload complete!"
'write data file details to table
writeAudit()
'check which account manager to alert and send email notification
emailNotify()
Else
lblMsg.Text = "File upload has failed - please try again..."
Exit Sub
End If
Public Sub New(ByVal hostname As String, ByVal port As Integer, ByVal username As String, ByVal password As String)
Me._hostname = hostname
Me._port = port
Me._username = username
Me._password = password
End Sub
Public Function putFile(ByVal localFile As String, ByVal remotePath As String) As Boolean
Try
transfer = New Sftp(Me._hostname, Me._username, Me._password)
transfer.Connect(Me._port)
transfer.Put(localFile, remotePath)
transfer.Close()
Return True
Catch ex As Exception
Dim objWriter As New System.IO.StreamWriter("C:\logfile.txt")
objWriter.Write(ex.Message)
objWriter.Close()
Return False
End Try
End Function
I have checked my sftp credentials and made sure that access from my web server to sftp server is valid and working. My log file is giving me the following exception message:
Could not find file 'c:\windows\system32\inetsrv\x.txt'.
I think I may be misunderstanding how the FileUpload control works here which may well be the crux of the problem
I'm not sure what the exact problem is but I would say that if you have tested your code and are happy it works, then this is not first place to start looking for problems. I would start with the configuration of the FTP server.
Hope this helps!
I have the following code (from msdn) to set file permissions:
' Adds an ACL entry on the specified file for the specified account.
Sub AddFileSecurity(ByVal fileName As String, ByVal account As String, ByVal rights As FileSystemRights, ByVal controlType As AccessControlType)
' Get a FileSecurity object that represents the
' current security settings.
Dim fSecurity As FileSecurity = File.GetAccessControl(fileName)
' Add the FileSystemAccessRule to the security settings.
Dim accessRule As FileSystemAccessRule = New FileSystemAccessRule(account, rights, controlType)
fSecurity.AddAccessRule(accessRule)
' Set the new access settings.
File.SetAccessControl(fileName, fSecurity)
End Sub
I call this using the group IIS_IUSRS (I've tried ComputerName/IIS_IUSRS too) and I'm trying to apply FileSystemRights.FullControl
But results in this error:
System.Security.Principal.IdentityNotMappedException: Some or all identity references could not be translated
Which suggests IIS_IUSRS doesn't exist (it does). My next step is to output the users and groups on the machine to see what my code thinks does exist. In the mean time does anyone know why, or what is causing this?
This code works fine on my local machine but not when run on my web server. The app pool runs as network service and Network Server has FULL permission on the folder the files are in. I noticed this question that suggests the user needs permission on the directory - but this isn't the problem.
To work around this, change the authentication on the website to run as "Same as app pool" (as opposed to anonymous). Not the best answer, but have tried everything else.
I have an asp.net website that needs to connect to a dBase file on a remote server. The remote server has a ODBC System DSN connection configured but I have no idea how to connect to it.
The ODBC connection on the server won't help you. The ODBC Connection needs to be set up on the machine you want to connect FROM, not the one you want to connect TO.
In order to connect to the DBASE files (and treat them like a database) you will need to
Map a drive so that you can access the location of the files..
Connect use the OleDbConnection.
It ALSO deals with a problem you will have reading DBase files from .NET. If you read them often enough, the app will start throwing a "System.Resources.Exceeded" exception. The only reliable solution I've found has been to kill the app and restart it, which is done in the code named FixMyself. (Not included as it contains sensitive data). The FixMyself routine essentially starts a second exe that kills THIS exe and then restarts it.
The sample code below is copied from production code, and should give you a push int he right direction. it maps the drive, connects, and reads.
It's ugly but it works. It's also only partial as it calls several functions not included here. But again, it should be enough to get you going.
Public Function GetRegisterConnectionString(ByVal PathToFolder As String)
Return "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & PathToFolder & ";Extended Properties=dBASE IV;User ID=Admin;Password="
End Function
Public Sub ReadMyDbaseFile(ByVal DriveLetter As String, ByVal IPAddress As String)
Dim DpalmPath As String = "\\" & IPAddress & "\c$\Dpalm"
Dim cn As New System.Data.OleDb.OleDbConnection("")
cn.ConnectionString = Me.GetRegisterConnectionString(DpalmPath)
If ds.Tables.Contains("CurrentPrices") Then
ds.Tables.Remove("CurrentPrices")
End If
Dim POSAdapter As New System.Data.OleDb.OleDbDataAdapter("select * From MyDbaseFile WHERE SomeField > 0 AND ACTIVE = -1", cn)
Try
POSAdapter.Fill(ds, "CurrentPrices")
Catch ex As Exception
If InStr(ex.ToString().ToLower(), "system resource exceeded") Then
WriteToLog("System Resource Exceeded Error was thrown on register " & DriveLetter & ", IP " & IPAddress & ".")
Me.FixMyself()
Else
Throw New Exception(ex.ToString())
End If
End Try
ds.Tables("CurrentPrices").Columns.Add("LastModified", GetType(Date))
POSAdapter.Dispose()
POSAdapter = Nothing
cn.Dispose()
cn = Nothing
ds.AcceptChanges()
GC.Collect()
End Sub