Skip to main content

A Webapp developed in .net and deployed at Azure (public) cannot be loaded in Add-in

SYang-10671
Original Poster

Hello, I'm new to Geotab Add-in development. Just created a simple Asp.Net Core WebApp with Razor pages and deployed to Azure. The web app is rendering fine by itself and accessible by public; but once I add an "Add-in" in My Geotab and configured the url to point to it, it seemed to only want to load briefly and then it disappeared. Behind the browser, there was some js lib errors that were not existing when the website is standalone.

 

According to your dev guide, there are two types of Add-ins, "Pages" and "Buttons" - "A custom page Add-in can be thought of as a complete web application inside your Geotab account".

 

But looks like there are some restrictions based on the issue I encountered. What are these restrictions? In my standalone web app, I also added CORS policy to allow origin from https://my.geotab.com.

 

Thanks for your time and attention.

Join the conversation

You need to be logged in to reply to this post and participate in the Geotab Community discussions.

8 Replies

EishiFUN
Geotabber

Hello @SYang-10671​ ,

 

Thank you for asking your question in our community. I apologize for the delay in answering your question. I am trying to find the best advice for you and I will reach out. In the meantime I will tag in a few community members who may be able to help here. Is this something you are familiar with @TuckerBA-1087​  or @DarenPorter-1148​ ?

 

I will let you know what I hear as soon as I do.

 

Have a good one!

Eishi FUN

SYang-10671
Original Poster
Hello, Thanks for getting back to me. After some more digging and readings, I realized that the main issue was that I expected the navigations and form posting currently working in a hosted Azure Web App would continue to work inside Geotab Add-in, but I shouldn't have. Now that I changed my expectation and implemented some JS logic to in the places where navigating between pages and form posting were needed , and it seemed to work for me now. Thanks, Steve Yang Sr. Developer Development [https://www.actsoft.com/emailimages/email_sig-phone_icon.jpg]813-936-2331 [https://www.actsoft.com/emailimages/email_sig-linkedin_icon.jpg][https://www.actsoft.com/emailimages/email_sig-facebook_icon.jpg][https://www.actsoft.com/emailimages/email_sig-twitter_icon.jpg]

The only experience I have with page add-ins is through JavaScript packages deployed as an add-in via the Geotab API. This sounds like the user is trying to effectively iframe their externally-hosted web application to the Geotab interface, which I'm not sure is possible, or how that might work if it is. It seems like Tucker has some good information on this though!

Hey @SYang-10671​,

 

Nothing you described is inherently incorrect. Do you have more information on what's happening? Like are there specific error codes you're receiving from the page load request or do you have any logs from the server to show that the request is making it there and not being blocked somewhere in the middle? Any additional information would help.

 

Thanks,

Tucker

SYang-10671
Original Poster

The issue now is that API call to any endpoint hosted in our Azure App Service is blocked when I ran the same app inside Geotab Add-in.

 

For example, you can browse to this public API test end point geotab-addin-test-amcsh0erb0gue5e8.eastus2-01.azurewebsites.net/api/GeotabDbStatus/status?dbname=localdb, and you will see result {"status":1,"url":null} as expected.

 

But when accessing the same API endpoint from a JS function after I added the page as an Add-in to my.geotab.com, nothing happened, and in the browser console it showed: "Failed to load resource: the server responded with a status of 404 (Not Found)"

 

I already configured our WebApp (Home page - Actsoft.Integrations.GeotabAddin.WebApp) CORS policy to accept my.geotab.com as origin.

 

Initially, I used relative path to access the API controller inside our web, and the API path became my.geotab.com/api/GeotabDbstatus/status?dbname=***. That of course did not work.

Hey @SYang-10671​,

 

Can you provide any additional information like the response headers you're getting on the 404 or can you log the exact API endpoint being hit by your add-in? Showing all request and response information would be helpful in debugging this.

 

Thanks,

Tucker

SYang-10671
Original Poster

Ok, It works now. The key is to use window.appConfigure to intercept the current httpcontext host address which I didn't.

window.appConfig.apiBaseUrl = '@($"{ViewContext.HttpContext.Request.Scheme}://{ViewContext.HttpContext.Request.Host}")'

Previously, I used:

apiBaseUrl = "https://geotab-addin-test-amcsh0erb0gue5e8.eastus2-01.azurewebsites.net"

 

 

Thanks for your time.

SYang-10671
Original Poster

Thanks for getting back to me. After some more digging and readings, I realized that the main issue was that I expected the navigations and form posting currently working in a hosted Azure Web App would continue to work inside Geotab Add-in, but I shouldn't have. Now that I changed my expectation and implemented some JS logic in the places where navigating between pages and form posting were needed , and it seemed to work for me now.  

 

Still have questions?