System.NullReferenceException: Object reference not set to object instance. Creating the Dotnetnuke module

I have an asp.net a script that gets the product name from the previous page and I get it like this:

<%
    strProductID = Convert.ToString(Request.QueryString("ProductID"))
    strLinkPath = "\DNN7\PRODUCTPDF\" + strProductID + ".pdf"
%>

      

and u assign this id as the PDF name, which is the same. I am trying to download this pdf from this link tag:

<a runat="server" class="pdfLink" href="<% =strLinkPath %>"><% =strLinkPath %></a>

      

and i get the error 'System.NullReferenceException: Object reference not set to an instance of an object. '

If I add the path directly to the label, it works fine:

strLinkPath = "\DNN7\PRODUCTPDF\1.pdf"

      

Also, if I put a dynamic print link on the label, I get the same path as the one I manually set and its value is equal to this: "\DNN7\PRODUCTPDF\1.pdf"

but the dynamic doesn't work and I keep getting this error.

What am I doing wrong here?

Server Error in '/DNN7' Application.

Object reference not set to an instance of an object.

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.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[NullReferenceException: Object reference not set to an instance of an object.]
   DotNetNuke.Entities.Urls.AdvancedUrlRewriter.Handle404OrException(FriendlyUrlSettings settings, HttpContext context, Exception ex, UrlAction result, Boolean transfer, Boolean showDebug) +165
   DotNetNuke.Entities.Urls.AdvancedUrlRewriter.RewriteUrl(Object sender, EventArgs e) +867
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +91
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +164

      

+3


source to share


1 answer


I removed runat = server and changed my path to this strLinkPath = "/ DNN7 / PRODUCTPDF /" + strProductID + ".pdf" and it worked



0


source







All Articles