Configure apple-app-site-association file and upload on server - ios

I am new on iOS development. I am implementing Universal Links in iOS App with ASP.net application.
I have define my associate domain in capabilities under Associated Domains:
applinks:www.abcd.com
And also configure in App Ids on Apple Developer Account. I think app side work is all set .
But I think problem with apple-app-site-association file.
I have written json in a simple text file like below
{
"applinks": {
"apps": [],
"details": [
{
"appID": "8T8932TY.com.AppName”,
"paths": ["*"]
}
]
}
}
Now I am stuck here. My application targeting on iOS 9 and above. I am confused that what is the extension of this file with naming apple-app-site-association. If I need to signed in with new certificates or not. And how upload it on server side.
Please guys help me out. I am searching lot for this but not get satisfactory answer.
Thanks

Your example JSON looks fine if substituted with real values for the AppID/AppName. You may want to be specific about what routes you handle but that's up to you - it's a better user experience to only try to handle routes that there's some chance you'll be able to handle, rather than opening your app for every link on your domain and kicking the user out to Safari again if that turns out not to be true.
The apple-app-site-association file should not have any file extension, and should be served from the root of your site, https://example.com/apple-app-site-association, and/or from https://example.com/.well-known/apple-app-site-association.
You say you're supporting iOS 9 and above - the change to check the .well-known route, which is checked first, came in iOS 9.3, so if you want to support below that OS, you're best off putting the file in both locations. See this answer for details.
It's also important that the file is served with the correct MIME-type, for Universal Links it can be served as application/json, and there's no need to sign/encrypt it. Getting it served with the correct MIME-type can be a little annoying if you're not familiar with configuration on your web server, as typically servers will determine the MIME-type from the file extension. You can't give it an extension, as iOS won't check the url with an extension and (IIRC) redirects are not allowed so you can't fake it by doing that either.
So that's a summary of what you're trying to accomplish, but how you do that depends on the web server you're using. For an ASP app that's likely to be IIS, in which case this question and its answers may help you configure your web server correctly. The details of how you upload a file to the root of that server will very much depend on how you've configured it as well.

There is no extension for this apple-app-site-association file. This is just a plain file. You have to host it on the top level of your domain meaning the file location will be https://www.abcd.com/apple-app-site-association Once you host it you can check/validate by using this link https://branch.io/resources/aasa-validator/
For detailed info please refer: https://blog.branch.io/how-to-setup-universal-links-to-deep-link-on-apple-ios-9/

This worked for me.
Created an empty .NET Core project and deployed it to the corresponding Azure web app service.
Using, Advanced tools in Azure portal, nvaigated to the Kudu files of the deployed app service.
Inside the folder "site/wwwroot/wwwroot" created a new folder named ".well-known".
Inside the newly created folder, created a new file named "apple-app-site-association.json".
Edited the newly created json file to hold the app details.
Modifed the file "site/wwwroot/web.config" for the following reasons:
a) Since iOS always calls the URLs without file extension mentioned (https://webapp-sftpint-employeeapp-dev.azurewebsites.net/apple-app-site-association)
we need to forcefully reqrite such URLs to have the file extension. Hence, added the rule in web.config
b) Since the response header should have "application/json" for the content returned from the static file "apple-app-site-association.json",
we added the explicit mentioning of the mimeType as "application/json".
So, the web.config file looks somewhat like this. (only the 'rewrite' and 'staticContent' blocks needs to be added additionally)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\yourproject.dll" stdoutLogEnabled="false" stdoutLogFile=\\?\%home%\LogFiles\stdout hostingModel="inprocess" />
<rewrite>
<rules>`enter code here`
<rule name="apple_json_file">
<match url="^apple-app-site-association" />
<action type="Rewrite" url=".well-known/apple-app-site-association.json" />
</rule>
</rules>
</rewrite>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</location>
</configuration>

Related

Windows protocol installer won't run from a browser

We have IT Hit WebDAV Server and IT Hit WebDAV Ajax Library running in a Windows development environment. All is working well except when a user tries to run the protocol installer from the webpage popup message. The popup says “Select OK to download the protocol installer”. When I click okay, it opens a new tab with a 404 error. I can see in the URL that it is looking in the correct folder, and the msi file IS in that folder.
I tried it in 3 different browsers with the same results. I also tried running the WebDavServer wizard project and get the same results. The only way I’ve found to get it to run from a browser is through the AjaxFileBrowser app. In there, the popup message is different and it works when you click the link for the Windows version.
Do you have any ideas for why it’s not running from the browser?
Here are some suggestions:
The MIME-map is not configured. By default IIS has a mapping for .msi and .gz extensions, but maybe it is deleted from IIS for some reason. Here is how to set MIME mapping in web.config:
<staticContent>
<mimeMap fileExtension=".pkg" mimeType="application/octet-stream" />
<mimeMap fileExtension=".deb" mimeType="application/octet-stream" />
<mimeMap fileExtension=".msi" mimeType="application/octet-stream" />
<mimeMap fileExtension=".gz" mimeType="application/x-gzip" />
</staticContent>
Your WebDAV Ajax Library files are located under the WebDAV path. Your server engine is processing all requests in your code so they do not reach the file system. Just move your static files to some other folder, outside of WebDAV. In case of IT Hit WebDAV samples, the static files are typically located in /AjaxFileBrowser/ folder.

comment code in MVC5 web.config in debug mode

When I deployed my app I had to add following code to my web.config file because otherwise the server won't display my .svg file
<system.webServer>
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<system.webServer>
However, if I leave that bit of code in the file while I develop on my machine, it leads to weird errors (e.g., my machine doesn't load my .css file anymore). All works fine if I comment that out again while working locally.
But exactly that is a hastle, commenting/uncommenting that code always when developing resp. deploying.
So my two questions:
1) Is there a way to include code conditionally in the web.config, e.g., depending on if degug or release build, or if deploying?
2) Why is that code causing trouble on my local machine in the first place?
UPDATE: So Q1 is answered, but still looking for an answer to Q2! Can't accept an answer before that ...
In your web.config File you have an arrow that points to two other Files called Web.Release.config and Web.Debug.config there you can make such changes. There you can modify your web.config based on your Run Mode.
There is a very good Microsoft Article about it im pretty sure it will help you
https://msdn.microsoft.com/en-US/library/dd465326(VS.100).aspx

How do I protect a file from direct download?

I have a webshop im developing, and some of the products need to be downloadable files (e-books, images, mp3 etc.). I have the files stored in a subfolder in my project and just a reference to them in my DB.
I dont want anyone with a direct file link to be able to download them, i want to control this myself. The download should only be available through my shop - that is, my customer area where the user can see all the e-products they have purchased.
How do i protect the files on my disk from being downloaded except by my code?
There are several ways to prevent the IIS static file handler from serving out the files to a client.
1) Using section in configuration. You can use the hiddenSegments element to specify sub-segment paths that will not be served. Look at %windir%\system32\inetsrv\config\applicationhost.config for how this section is defined and used to prevent access to bin folder and other directories.
<configuration>
<system.webServer>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="subdirectoryName" />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</configuration>
2) If you're looking for a simpler "poor-mans" way of blocking static file handler from serving out files, you can make the files "hidden" (from a file system attribute perspective). The static file handler will not serve out hidden files.
The easy answer: Don't place these files inside your site, place them outside the root of your site.
You can configure IIS to not serve requests to this folder with request filtering:
I'm assuming these paths are not paths you wanted to serve?

Publishing an MVC4 App on IIS 7.5 but Having Permission Issues

I published an intranet on IIS 7.5. If I try to go to the website, I get "403 - Forbidden: Access is denied - You do not have permission to view this directory or page using the credentials that you supplied".
If I right click on the application folder on IIS Manager and go to Manage Application and then Browse, I get "HTTP Error 403.14 - Forbidden - The Web server is configured to not list the contents of this directory". It then proceeds to tell me that A default document is not configured etc. etc. I do have a default document listed in the web.config file as follows:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<modules runAllManagedModulesForAllRequests="true" />
<defaultDocument>
<files>
<add value="Index.cshtml" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
What am I doing wrong? Many thanks.
check the folders permissions: right click on the folder, click on properties go to Security and add the appropriate user (like IUSR_...). hope it helps.
It turned out I was publishing the app completely the wrong way. I was going by how previous ASP.Net apps created as Websites and not Solutions were published. This MVC app needed to be placed in inetpub/wwwroot folder in the server. If I published through Visual Studio I think this would have happened anyway. I didn't have VS in the server. So I placed the files manually there (just copied from my local inetpub/wwwroot since I successfully published there earlier). The last thing I needed to do was go to IIS Manager and converting the project folder into an Application. Now cooking on gas.

.OTF font not being deployed to Azure

I have an MVC 4 application with an .otf font in the /images folder. It works on my desktop, but when I deploy to azure I get a 404 when trying to access /images/myfont.otf
The font already has the Build Action property set to 'Content'
How can I force Azure to pick this up?
You probably need to configure the IIS to properly serve this file type. You do this by adding the following to the <system.webServer> element in Web.config:
<staticContent>
<mimeMap fileExtension=".otf" mimeType="font/otf" />
</staticContent>
More info
http://www.big.info/2013/06/how-to-use-otf-opentype-format-fonts-on.html
Place the following in web.config in the system.webServer configuration:
<system.webServer>
<staticContent>
<remove fileExtension=".otf" />
<mimeMap fileExtension=".otf" mimeType="font/otf" />
</staticContent>
</system.webServer>
HTTP Error 404 means the content is not found on server. It does mean that when you deploy your application to Windows Azure the content was not in the package.
As you suggested above that you do have .OTF set as content it means that you are asking compiler to treat it as static file and don't build it however specific file will not be copied to the final output folder to be the part of final CSPKG. You would need to set "Copy to output directory" as "copy always" so it can be part of CSPKG and deployed to Azure Cloud service.
Once you set file properties correctly and build your application, you can manually visit to your output folder to the verify that file is there as well as your CSPKG just by unzipping it.
The problem for me is that the files weren't included with the project. They were in the correct file path ((project)/Content/fonts/*), but not considered part of the project (i.e. references by the *.csproj file). The solution was to right click the fonts folder and choose the Include in Project option.
My best bet is that you've got relative paths to your font files within your css.
Are you getting a 403 Forbidden? That might indicate that your filepath's are off.
Try changing your paths from ../filename.otf to something like /Styles/filename.otf (or whatever your path is)

Resources