File.open file creation error - asp.net

I'm trying to create a file using:
Dim stmFile As Stream = File.Open(filename, FileMode.OpenOrCreate, FileAccess.Write)
This should create a file as the file specified does not currently exist however instead it throws a server error:
Could not find a part of the path 'c:\tempemail\681968_File.doc'.
Description: An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and where
it originated in the code.
Exception Details: System.IO.DirectoryNotFoundException:
Could not find a part of the path 'c:\tempemail\681968_File.doc'.
Any advice?

Try the following
Ensure that the tempemail exists
Ensure that the application pool user has write permission to the folder.

Related

Logon failed issue after report deployment

if (!IsPostBack)
{
rprt.Load(Server.MapPath("~/report/CrystalReport2.rpt"));
DataSet ds = obj.Getds("rpt_details");
rprt.SetDataSource(ds);
CrystalReportViewer1.ReportSource = rprt;
Session["ReportDocument"] = rprt;
}
On localhost, the report runs properly. But once deployed to the server it gives this error:
Logon failed. Details: mscorlib : The device is not ready. Error in File C:\Windows\TEMP\CrystalReport2 {BAC2FF3C-45D2-47FC-9AED-7FD5B8D2CC5E}.rpt: Unable to connect: incorrect log on parameters.
I deployed and published all files, including datatable1.xsd and the files folder.
look in your rpt file and make sure you provide a user name and password for the database connection or add the database user credentials to your code and pass then from the web.config

Insight messages not showing in Visual Studio or Azure

Im seeing AI messages in the debug window but not in the diagnostics window/ hub , Azure or the application insights VS screens,
Debug window
Application Insights Telemetry: {"name":"Microsoft.ApplicationInsights.e71aa06ae1d142b4ae04393d63a71d57.Exception","time":"2016-07-16T09:46:37.7435251Z","iKey":"xyz","tags": etc
Not using a config file
for (;;)
{
var telemetryClient = new TelemetryClient();
telemetryClient.InstrumentationKey = "abc";
telemetryClient.Context.Session.Id = Guid.NewGuid().ToString();
telemetryClient.Context.User.AccountId = "Ben";
telemetryClient.Context.Component.Version = "1.0";
telemetryClient.TrackEvent("Application Start");
telemetryClient.TrackException(new ApplicationException("test exc"));
telemetryClient.Flush();
Thread.Sleep(3000);
}
This is in several solutions One a Console the other .Core . Any ideas ?
Add diagnostics shows.
Value for property 'Failed to load an item from the storage. file: 20160531051527_dbd26772482e4dbab6791b63f0ded9d3.trn Exception: System.UriFormatException: Invalid URI: The format of the URI could not be determined.
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
at Microsoft.ApplicationInsights.Channel.Storage.Peek()' of vshub.exe was not found. Populating it by default.: OnNext: {0}
Value for property 'Failed to load transmission from file. File full path: C:\Users\bklooste\AppData\Local\Microsoft\ApplicationInsights\vstelAIF-312cbd79-9dbb-4c48-a7da-3cc2a931cb70\20160712090841_9436f519411b4a10b4f551897382fcc6.trn, Exception: System.UriFormatException: Invalid URI: The format of the URI could not be determined.
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
at Microsoft.ApplicationInsights.Channel.Storage.d__14.MoveNext()' of vshub.exe was not found. Populating it by default.: OnNext: {0}
Value for property 'Failed to load an item from the storage. file: 20160712090841_9436f519411b4a10b4f551897382fcc6.trn Exception: System.UriFormatException: Invalid URI: The format of the URI could not be determined.
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
Possibly not an answer but will help those who search for this stack trace and don't read the comments on the question.
The OPs question was resolved when they checked the Instrumentation Key.
The stack trace is generated by vshub.exe when it attempts to read the files at C:\Users\bklooste\AppData\Local\Microsoft\ApplicationInsights\vstelAIF-312cbd79‌​-9dbb-4c48-a7da-3cc2a931cb70 to send in the offline telemetry.
This offline telemetry is provided by the Application Insights Persisted HTTP package. Without knowing the actual contents of the file it seems likely there is some corruption in the file. The file should look something like the snippet below. If for some reason the file was truncated or the URI is actually malformed then this exception will be thrown.
You either need to correct the URI, or (preferrably) just delete the file.
https://vortex.data.microsoft.com/collect/v1
Content-Type:application/x-json-stream
Content-Encoding:gzip
H4sIAAAAAAAEAJV...

Parse XML from an online source

I'm attempting to parse the xml located at view-source:http://www.parkrun.com.au/wp-content/themes/parkrun/xml/geo.xml. This is my first attempt at doing this type of thing so my knowledge is limited. I've parsed plenty of websites but not xml.
I've attempted the following code but keep getting an error:
Dim xdoc As New XmlDocument
xdoc.LoadXml("http://www.parkrun.com.au/wp-content/themes/parkrun/xml/geo.xml")
Error: {"Data at the root level is invalid. Line 1, position 1."}
What I'm attempting to do is parse the xml and then loop through the records to build an array based on each location and state (eg from below it would be ipswichqld, Queensland). For example below ipswichqld belongs to Queensland (r="4" joins with id="4").
Any help on this would be really appreciated, thanks in advance.
Instead of LoadXml() method, you should've used XmlDocument.Load() method to load XML from local or online source file :
Dim xdoc As New XmlDocument
xdoc.Load("http://www.parkrun.com.au/wp-content/themes/parkrun/xml/geo.xml")
Unfortunately, particular website you're trying to load XML from doesn't allow this operation (not even if you open that XML URL from browser). I got this exception when trying above code :
WebException
The remote server returned an error: (403) Forbidden.

ASP.NET site authorization issue with google and youtube api's

I have implemented several google APIs in my website - to enbale contacts import and youtube uploads.
while everything works great locally (under my own development server's localhost), there are some problems using them thru the site (hosted on both HostGator and 1and1 and i get the same errors everywhere) - seems like
authentication problems.
the site is on ASP.NET 2.0 and these are the error msgs i get:
Error For google contacts (using AuthSub) - this happens after the I successfully receive a session token from google's authsub:
The remote server returned an error: (401) Unauthorized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote server returned an error: (401) Unauthorized.
Source Error:
Line 493: ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));
Line 494:
Line 495: ContactsFeed feed = service.Query(query);
Line 496:
Line 497: ArrayList emails = new ArrayList();
Source File: d:\inetpub\vhosts\e-koren.com\httpdocs\home-cooking\EmailInvite.aspx.cs Line: 495
Error For youtube video uploading (using ClientLogin):
Invalid credentials
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: Google.GData.Client.InvalidCredentialsException: Invalid credentials
Source Error:
Line 71: // try
Line 72: // {
Line 73: FormUploadToken _token = request.CreateFormUploadToken(newVideo);
Line 74:
Line 75: actionURL.Value = _token.Url + "?nexturl=" + Server.UrlPathEncode(Request.Url.ToString()+"?uuc=");
Source File: d:\inetpub\vhosts\e-koren.com\httpdocs\home-cooking\youtubeUpload.aspx.cs Line: 73
Anyone knows what could it be?
Thanks,
Asaf
I managed to slove it eventually:
as for the first error (authsub and google contacts) - I changed the URI from "http" to "https":
// V1
GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory("cp",gn.ytApplicationName);
authFactory.Token = (String)Session["token"];
ContactsService service = new ContactsService(authFactory.ApplicationName);
service.RequestFactory = authFactory;
ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));
// VERY IMPORTANT! adding HTTPS resolves google's bug (401 error)
query.Uri = new Uri("https://www.google.com/m8/feeds/contacts/default/full");
ContactsFeed feed = service.Query(query);
about the 2nd error (ClientLogin) - appearantly google have tightened the security measures around this kind of method - they send a warning email to the user that I wanted to log in through - and only if he follows several complex steps they authorize access to his videos.
As I found out this is not an error, but a policy, I think I'll just switch to AuthSub there too.
Hope I could help someone else too...
:)

getting HTTP Status 500 when location href or when forwarding from Servlet?

I get this error:
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.NullPointerException
root cause
java.lang.NullPointerException
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1-b24 logs.
GlassFish Server Open Source Edition 3.1-b24
when I try to forward from a jsp to another jsp or when I forward in a servlet... The thing is that Y modify some datils from my page and I want to go back to the login-page and log in again to see if the update was successful !... Any ideas on this error ?... Thankx
A NullPointerException is a rather trivial exception and has actually nothing to do with JSP/Servlets, but with basic Java in general (look, it's an exception of java.lang package, not of javax.servlet package). It just means that some object is null while your code is trying to access/invoke it using the period . operator.
Something like:
SomeObject someObject = null;
someObject.doSomething(); // NullPointerException!
The 1st line of the stacktrace tells you in detail all about the class name, method name and line number where it occurred.
Fixing it is relatively easy. Just make sure that it's not null or bypass the access altogether. You should rather concentrate on why it is null and/or why your code is trying to deal with null.

Resources