Get Site URL stored in solution properties SiteURL - c#

Currently working on creating custom function for a SharePoint site, i have inserted Site URL on the SharePoint project folder, is it possible i retrieve the Site URL from the project properties to use in .cs file within it?

Site URL in a project you set for the possibility to deploy solution to SharePoint via Visual Studio. If you want to get current Web url from code you can use SPContext:
SPContext.Current.Site.Url - for the site collection url,
SPContext.Current.Web.Url - for the current Web url.

Related

Error: redirect_uri_mismatch In Google Login in MVC Application

I am trying to upload video to YouTube through MVC C# application. I am following this link
Whenever I am trying to run the application I am getting below error from the Google.
Error: redirect_uri_mismatch
The redirect URI in the request, http://localhost:52271/authorize/, does not match the ones authorised for the OAuth client. Visit https://console.developers.google.com/apis/credentials/oauthclient/CCC-XXX.apps.googleusercontent.com?project=XXXX to update the authorised redirect URIs.
Here is my Json file.
Here is my Google Console Application:
Error:
Is there anything wrong ?
Thank You.
The redirect URI you set in Google Developer console must exactly match where you are sending the request from. If you notice the Port number is changing. This is because visual studio has a habit of adding random port numbers when you are debugging via visual stuido.
To specify a port for a Web application project that uses IIS Express
In Solution Explorer, right-click on the project and then select Properties. Click the Web tab.
In the Servers section, under Use Local IIS Web server, in the Project URL box change the port number.
To the right of the Project URL box, click Create Virtual Directory, and then click OK.
In the File menu, click Save Selected Items.
To verify the change, press CTRL+F5 to run the project. The new port number appears in the address bar of the browser.
How to: Specify a Port for the ASP.NET Development Server
From Google doc located at https://developers.google.com/identity/protocols/OAuth2UserAgent?hl=en_US#example
The REDIRECT_URI should be the same URL where the page is being served.
I finally saw this, put the URL for the page where I call the Google authentication, and it worked like a charm.
You need to add localhost to your authorized domain names in the Google API Console.

Ajax url after publish site

I developed a site in asp.net. In my site, I have an ajax post which worked when I ran the site locally.
After I publish my site, it looks like the url for ajax post is changed.
I want to align the URL that when running the site locally will be the same as when the site is published
I published the site under folder name ResourceManager (it also the site name)
My ajax URL before publish the site
URL= "/testbed/ConnectTesbedToResource/";\\(<controller_name/method_name>)
after publish the site its NOT working and I need to change the URL to
URL = /ResourceManager/TestBed/ConnectTesbedToResource/;
How I can make sure that the URL will be the same for local run and for publish run?
I tried to change the URL to relative path with ~ (~/testbed/ConnectTesbedToResource/) and it also didn't work.
How can I make that after publish I will have same URL for jQuery post request?
Use URLs without a / at the start - / will make it relative to the site root, which, as you've seen, can change depending on the config of the server and where you install to. Without the / it will be relative to the current page, which is much easier to handle across different install locations

Sharepoint 2013: My sharepoint solution doesn't contain default.aspx page

I created a sharepoint application in which I added a web app item , but the problem i didn't find the default.aspx page
Once you have the web application, you need at least a site collection to be able to navigate to. Once you create a site collection, every site in it (including the root site) will have a page called Home.aspx - that's the default one for SharePoint, not default.aspx - which you can browse. Also by default, navigating to a site's URL without a page name in the URL will lead you to Home.aspx.
Edit, to answer OP's comment:
i created a new web part in visual studio in order to deploy it in my Sharepoint site. In visual studio , i created an empty sharepoint project in which i added a web part to it , the problem i didn't find the default.aspx page in the project that i created
Web part and visual web part projects don't include pages. You may include a page in a module if you wish, but you will have to create it yourself.
Also, visual web parts are more like user controls than ASP.NET pages. You create these to add to web part zones pages. If you want to deploy pages, you might want to choose another project type.

SharePoint 2013 - Accessing List data through web service from Sharepoint site, getting error 404

I have been trying to get the list data from Sharepoint 2013 Site for many days but no luck. I stuck to the point where I don't know what could be the reason.
I have created a Sharepoint 2013 provider Hosted app on the development server. I have a list with data on the azure site (Production) and I am trying to access that data through the web service. Somehow I am able to connect to the service using URLs like "http: //mydomain/sites/sitename/_vti_bin/Lists. asmx" while adding the webreference to my project. This link is also showing the right values while Opened in browser with right credential but the problem is that when I Click on create web reference button it gave me an error that wsdl cannot be downloaded.
So this is the message when I click on the service description , it doesn't show the xml file that supposed to show.
Please look at the link below for more clarification on my question:
http://social.msdn.microsoft.com/Forums/en-US/ca6ec22b-bad5-466a-b811-08c515479ef1/sharepoint-2013-accessing-list-data-through-web-service-from-sharepoint-site-getting-error-404?forum=sharepointdevelopmentprevious

Load asp.net website inside winform C#

I have a(n) (MDI) Windows Form application. It contains two forms. One form (Measured data) controls an engine, another form (laboratory) should show my asp.net web site that has various assignments for the user to do.
How can I show the asp.net default page in that laboratory form? I'm using awesomium to make a browsing window in my laboratory form.
Doing the following
webView.LoadURL("file:///D:/school/4e%20jaar/Erasmus/ErasmusProject/Laboratory/deault.aspx");
gives an error. Probably because the asp.net site isn't online. but how can I run the site so I can see the default.aspx page?
I have on solution with three projects
ErasmusProject
ASP.NET website
SIMOclasses
SIMOForm
The problem is you cannot execute aspx files with file:/// path.
You have to execute on IIS.
So first thing you have to do setup iis if you didnt, create new web site (or use Default Web Site) to execute your aspx files, than change your link file:/// to http://localhost or something.
The URL you've specified looks like its accessing the raw file via the file system. i.e. file:///D:/.../default.aspx.
(You've also misspelt 'default' in your question!)
Can you access that URL from a browser (e.g. IE, Firefox, etc) and see the content you want? I suspect you can't and that you're missing the webserver that is compiling and serving the .aspx pages.
You should host your website first :
WebDev.WebServer /port:9999 /path:"C:\Projects\MyWebSite"

Categories