问题
I have the following requirement,
When an URL is requested in the azure web site for a file, then the file available in root folder has to return to "application/JSON"
Say for example:
I have a file called "apple-app-site-association", which is a text file which has JsonData available in the root folder of a web site in azure. When we enter the URL in browser "mydomain.com\appleConfiguration", that should return the JSON text in the browser.
The file "apple-app-site-association" should not have the extension of ".Json"
I tried using the following ruleset in the web.config, believe the rule set is not accurate, can some one suggest this.
This works fine in IIS but not in Azure hosted site.
<rule name="Apple Universal Links" stopProcessing="true">
<match url="^apple-app-site-association$"/>
<action type="Redirect" redirectType="application/json" url="^apple-app-site-association$"/>
</rule>
回答1:
Follow the simple five steps to make this working,
1) Create the "apple-app-site-association" with the mobile configuration JSON content and store to the local system.
Sample configuration in the file "apple-app-site-association":
{
"applinks": {
"apps": [],
"details": [
{
"appID": "9JA89QQLNQ.com.apple.wwdc",
"paths": [ "/wwdc/news/", "/videos/wwdc/2015/*"]
},
{
"appID": "ABCD1234.com.apple.wwdc",
"paths": [ "*" ]
}
]
}
}
2) Copy the.Json file to your root directory of the azure folder "wwwroot"
3) If the json file is not available or protected to read in your website, then use the mime configuration to enable the .json file to display in the web site
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
4) Create a rule in the "web.config" file, which will provide the Json value when the Applebot robot crawl your site for the apple association
<system.webServer>
<rewrite>
<rules>
<rule name="apple_json_file">
<match url="^apple-app-site-association" />
<action type="Rewrite" url="apple-app-site-association.json" />
</rule>
</rules>
</rewrite>
</system.webServer>
5) Check the Json value is displayed in your web site properly, when you enter the following URL in browser,
https://yourDomain/apple-app-site-association
or
http://branch.io/resources/aasa-validator/
Note: Modify the with valid website Domain name.
if this works fine then Go to the validator site
https://search.developer.apple.com/appsearch-validation-tool
Check the Universal links are valid for your web site.
回答2:
I want to add my state into previous answer by Bhuvnesh Mohankumar.
In step #2, after copy "apple-app-site-association" file in wwwroot, we are unable to validate our AASA file on step #5.
So here is my find for this issue as below.
If by following all the steps and any still facing the issue in validating AASA file, please copy two files "apple-app-site-association" and "apple-app-site-association.json" in wwwroot azure server.
来源:https://stackoverflow.com/questions/43053398/apple-app-site-association-to-return-as-application-json-from-a-azure-request