basic problem

  • Thread starter Thread starter Loui Mercieca
  • Start date Start date
L

Loui Mercieca

I have a very basic problem, but can't seem to solve it. Whenever i try to
use the mappath, an error is thrown ( System.NullReferenceException: Object
reference not set to an instance of an object.) and whenever i try to use
the response.redirect another error is thrown ( not valid under this
context ). In order to solve this problem, i am contrantly passing my
default page as a parameter and use it ( ex,
DefaultPageInstance.MapPath() ). However this is not proper coding.

Can anyone place me on the right track?
 
I'm not sure i understand your problem.
Maybe pasting some of your code might help .

Anyways, here some pointers.

MapPath

Server.MapPath --> this must point to a relative path that EXISTS!
NullReferenceException means it doesn't
So say you trying to get the path of a file called 'MyFile.pdf' in the same
directory your aspx page running is.
Use:
Server.MapPath("MyFile.pdf");
Or if it is in a sub folder called pdf:
Server.MapPath("pdf/MyFile.pdf");

Get my drift, it has to be relative.


Response.Redirect

Again ,relative
Response.Redirect("default.aspx"); //in the same folder
Response.Redirect("/default.aspx"); //root of you website


HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top