Refreshing the CRM loader page crashed my custom aspx page

คำตอบ Refreshing the CRM loader page crashed my custom aspx page

  • 7 มีนาคม 2551 2:55
     
     

    With a lot of help from the forum, my aspx page is now functionally to spec except for this one bug. 

     

    My aspx page grabs data from a CRM entity and populates a DropDownList on page_load in code-behind.  I click Save button and it reloads and updates the changed data to the entity and window.opener.location.reload() the loader.aspx page so that I can see the changes. 

     

    I then click the button on the loader.aspx (actually it lives on the home_pages.aspx) and my asp webpage loads again and authenticates once more and grabs the data from the CRM entity again to load the dropdownlist just fine, however, when I hit the save button, i get this error:

     

     

    The request failed with HTTP status 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 request failed with HTTP status 401: Unauthorized.

    Source Error:

    Line 146:        [return: System.Xml.Serialization.XmlElementAttribute("Response")]
    Line 147:        public Response Execute(Request Request) {
    Line 148:            object[] results = this.Invoke("Execute", new object[] {
    Line 149:                        Request});
    Line 150:            return ((Response)(results[0]));

    Source File: F:\CritSit\Handover\Web References\CrmSdk\Reference.cs    Line: 148

    Stack Trace:

    [WebException: The request failed with HTTP status 401: Unauthorized.]
       System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +551137
       System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +204
       Handover.CrmSdk.CrmService.Execute(Request Request) in F:\CritSit\Handover\Web References\CrmSdk\Reference.cs:148
       Handover._Default.Page_Load(Object sender, EventArgs e) in F:\CritSit\Handover\Default.aspx.cs:77
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +47
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
    


     

    anyone know of a fix for this? Thanks.

     

     

ตอบทั้งหมด

  • 7 มีนาคม 2551 9:31
    เจ้าของ
     
     

    Where do you locate your aspx page?

    Have you create a virtual directory under CRM website?

     

    Jim

  • 7 มีนาคม 2551 10:41
     
     

    Hi.

     

    I suggest the following options:

     

    1. Don't refresh the entire loader.aspx just the inner iframe:

        opener.frames['stage'].location.reload();

    2. I think you'll be better off if the save button does its jobs and also closes the aspx page unless an error occurred.

     

    If the above solutions do not work for you tell I and we'll dig further.

     

    Cheers,

    Adi   

     

     

  • 7 มีนาคม 2551 23:02
     
     

    Yes, my aspx page lives inside CRM as a virtual directory.

     

    I was updating the parent frame (home_cases.aspx) as my application closes. the entire CRM pages resides at loader.aspx.

     

    It works fine as long as the parent page doesn't refresh. I complete my aspx logic, execute my crmservice and exit without refreshing the parent page works just fine, but one of the later functionality specs requires that the CRM pages refreshes and reloads itself every 10 mins, so this will in turn break my aspx page.

     

    As for right now without reloading the pages, my aspx page works just fine.

     

    I'm just tempted to make my own data access layer and make my normal sql calls to update the 3 fields needed.  I can bypass the crm authentication and just use the network default credentials.

  • 12 มีนาคม 2551 0:53
     
     

    Hi Adi!

     

    I tried :

    window.opener.frames['stage'].locations.reload();

    to refresh the stage frame in loader.aspx and it doesn't do anything.  is it because the page is loaded from the buttons frame?

     

  • 12 มีนาคม 2551 1:10
     
     

    Change:

    window.opener.frames['stage'].locations.reload();

    To

    window.opener.frames['stage'].location.reload();

     

    Adi

     

  • 12 มีนาคม 2551 1:46
     
     

    sorry, I did have that "s" from "locations" removed, I just typed it out wrong when posting it here.

     

    window.opener.frames['stage'].location.reload();

    self.close();

     

    still does not load the parent window or close my popup window.

     

    This:

     

    window.opener.location.reload();

    self.close();

     

    still works though, except I get an the 401 unauthorized message when I try to re-run the page.

     

    Thanks.

     

  • 12 มีนาคม 2551 2:05
     
     คำตอบ

    Hi.

     

    alert( opener.location.href ); // witch URL are you seeing?

    If the popup is opened from the top_bar.aspx then you need to change the script a bit.

     

    To something like;

    window.opener.top.frames['stage'].location.reload();

     

    I'll be sure once you paste the opener location here.

     

    Adi

     

  • 13 มีนาคม 2551 22:40
     
     
    The alert(opener.location.href) does return home_cases.aspx. I did place my javascript here to launch my window.open().

     

  • 14 มีนาคม 2551 1:54
     
     

    I got this fixed by putting the actual network credentials (administrator/password/domain) in my web.config and used it for CrmService.Credentials and just made a javascript to launch my aspx page and put in the user's GUID and incident's GUID in the query string.

     

    Thanks Adi for the help! great advice as usual.