We're sorry GroupDocs doesn't work properply without JavaScript enabled.

Free Support Forum - groupdocs.com

Document viewer MVC example does not work in IIS

Your MVC example works fine with IIS express but when we try to work with IIS we are not able to make it work

image.png (9.1 KB)


This Topic is created by vladimir.litvinchik using Email to Topic tool.

@supahoops

We’re looking into this issue and update you here.

@supahoops

By default, the client app expects that the API methods are available at the /viewer path but when you’re deploying to IIS all API methods now at the root path /. So, the client app is trying to call /viewer/loadConfig when it should be just /loadConfig. To update client app configuration you can go to app.module.ts and update it with the following code

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { APP_BASE_HREF } from '@angular/common';
import { AppComponent } from './app.component';
import { ViewerModule } from "@groupdocs.examples.angular/viewer";
import { ConfigService, Api } from '@groupdocs.examples.angular/common-components';

function createViewerConfig() {
  const config = new ConfigService();
  config.getConfigEndpoint = () =>  Api.LOAD_CONFIG; // default is '/viewer' + Api.LOAD_CONFIG
  config.getViewerApiEndpoint = () => '/'; // default is '/viewer'
  return config;
}

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule,
    ViewerModule],
  providers: [
    { provide: APP_BASE_HREF, useValue: '/' },
    { provide: ConfigService, useFactory: createViewerConfig }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

This changes will point client app to the root path instead of /viewer path when calling the server.
Please let us know if this solution works for you.

Thank you for your help. we manage to load group docs viewer in IIS but we got issue with resource not loading.
https://dev-inlinedocumentviewer.eteach.com/viewer/resources/833d3e08-6851-42b7-aafe-579e100265ce_pdf/p1_i.png
image.png (107.9 KB)

@supahoops

Please also update HTML resource path this line

- var urlPrefix = "/viewer/resources/" + Path.GetFileName(this.filePath).Replace(".", "_");
+ var urlPrefix = "/resources/" + Path.GetFileName(this.filePath).Replace(".", "_");

And cleanup the cache folder src\DocumentSamples\Viewer\cache\.

Thank you for your response. It work as expected. I got two more questions:
1: how do we create unique fileCacheSubFolder?? In our case url can "DataFiles\EmpDocs\54808\ApplicationForms\teacher.docx for client A and “DataFiles\EmpDocs\54809\ApplicationForms\teacher.docx” for client B. As you have notice both file name exactly same. So it will create “teacher_docx” fileCacheSubFolder. So how can we create unique fileCacheSubFolder for each file which has different location?
2: In our case - file viewer only should be accessable for logged in user. we are planning to use viewer as iframe, how do we secure group docs viewer?

thanks

@supahoops

I’m sorry for the delayed response. Please follow this topics